Skip to content

Commit

Permalink
feat(Core/qualifiedtype): recognise type aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
tecosaur committed Oct 13, 2024
1 parent dc0edff commit 31211d7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Core/src/model/qualifiedtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ QualifiedType(m::Symbol, parents::Vector{Symbol}, name::Symbol) =

function QualifiedType(::Type{T0}) where {T0}
T = Base.unwrap_unionall(T0)
params = map(p -> if p isa Type
QualifiedType(p)
else p end,
T.parameters)
alias = Base.make_typealias(T)
root, name, params = if isnothing(alias)
parentmodule(T), nameof(T),
map(p -> if p isa Type QualifiedType(p) else p end,
T.parameters)
else
alias::Tuple{GlobalRef, Core.SimpleVector}
first(alias).mod, first(alias).name,
map(p -> if p isa Type QualifiedType(p) else p end,
collect(last(alias)))
end
parents = Symbol[]
root = parentmodule(T)
while root != parentmodule(root) && root (Base, Core)
push!(parents, nameof(root))
root = parentmodule(root)
end
QualifiedType(nameof(root), parents, nameof(T), Tuple(params))
QualifiedType(nameof(root), parents, name, Tuple(params))
end

Base.:(==)(a::QualifiedType, b::QualifiedType) =
Expand Down

0 comments on commit 31211d7

Please sign in to comment.