Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check type name is a type, Fix #487 #488

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TypedSyntax/src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function type_annotation_mode(node, @nospecialize(T); type_annotations::Bool, hi
type_annotate = is_show_annotation(T; type_annotations, hide_type_stable)
pre = pre2 = post = ""
if type_annotate
if T <: Type
if T isa Type && T <: Type
# Don't annotate `String::Type{String}`
if replace(sourcetext(node), r"\s" => "") == replace(sprint(show, T.parameters[1]), r"\s" => "")
return false, pre, pre2, post
Expand Down
9 changes: 9 additions & 0 deletions TypedSyntax/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,15 @@ include("test_module.jl")
# issue #435
tsnc = copy(tsn)
@test isa(tsnc, TypedSyntaxNode)

# issue 487
m = which(TSN.f487, (Int,))
src, rt = getsrc(TSN.f487, (Int,))
rt = Core.Const(1)
tsn, _ = TypedSyntax.tsn_and_mappings(m, src, rt)
@test_nowarn str = sprint(tsn; context=:color=>false) do io, obj
printstyled(io, obj; hide_type_stable=false)
end
end

if parse(Bool, get(ENV, "CI", "false"))
Expand Down
3 changes: 3 additions & 0 deletions TypedSyntax/test/test_module.jl
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,7 @@ MyDict{T} = Dict{T,Any}
f482a(x) = MyDict{String}(x)
f482b(x) = Dict{String,Any}(x)

# Issue 487
f487(x) = 1

end
Loading