diff --git a/TypedSyntax/src/show.jl b/TypedSyntax/src/show.jl index 91244972..79361ca5 100644 --- a/TypedSyntax/src/show.jl +++ b/TypedSyntax/src/show.jl @@ -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 diff --git a/TypedSyntax/test/runtests.jl b/TypedSyntax/test/runtests.jl index b859dd3a..bc880f3a 100644 --- a/TypedSyntax/test/runtests.jl +++ b/TypedSyntax/test/runtests.jl @@ -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")) diff --git a/TypedSyntax/test/test_module.jl b/TypedSyntax/test/test_module.jl index 570e22dc..2cfc430b 100644 --- a/TypedSyntax/test/test_module.jl +++ b/TypedSyntax/test/test_module.jl @@ -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