Skip to content

Commit

Permalink
Relax to handle qualification
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Aug 5, 2024
1 parent ee3b8c4 commit ab10c89
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion TypedSyntax/src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ function is_show_annotation(@nospecialize(T); type_annotations::Bool, hide_type_
end

# Is the type equivalent to the source-text?
is_type_transparent(node, @nospecialize(T)) = replace(sourcetext(node), r"\s" => "") == replace(sprint(show, T), r"\s" => "")
# We use `endswith` to handle module qualification
is_type_transparent(node, @nospecialize(T)) = endswith(replace(sprint(show, T), r"\s" => ""), replace(sourcetext(node), r"\s" => ""))

function is_callfunc(node::TypedSyntaxNode, @nospecialize(T))
pnode = node.parent
Expand Down
5 changes: 5 additions & 0 deletions TypedSyntax/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,11 @@ include("test_module.jl")
printstyled(io, obj; hide_type_stable=false)
end
@test occursin("::Core.Const(sin)", str) || occursin("::typeof(sin)", str)
tsn = TypedSyntaxNode(TSN.calls_helper, (Float32,))
str = sprint(tsn; context=:color=>false) do io, obj
printstyled(io, obj; hide_type_stable=false)
end
@test !occursin("Core.Const", str)

# issue #413
@test TypedSyntax.is_small_union_or_tunion(Union{})
Expand Down
7 changes: 7 additions & 0 deletions TypedSyntax/test/test_module.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,11 @@ function obfuscated(x)
return f(x)
end

module Internal
export helper
helper(x) = x+1
end
using .Internal
calls_helper(x) = helper(x)

end

0 comments on commit ab10c89

Please sign in to comment.