level = 0
function showtypetree(subtype)
global level
subtypelist = filter(asubtype -> asubtype != Any, subtypes(subtype))
if length(subtypelist) > 0
println("\t" ^ level, subtype)
level += 1
map(showtypetree, subtypelist)
level -= 1
else
println("\t" ^ level, subtype)
end
end
showtypetree(Number)
ignore{T<:Any}(value::T)::Void = return
function showtypetree(subtype::DataType)::Void level::Int64 = 0 function nested(st::DataType)::Void subtypelist = filter(asubtype -> asubtype != Any, subtypes(st)) if length(subtypelist) > 0 println("\t" ^ level, st) level += 1 for s in subtypelist nested(s) end ignore(level -= 1) else println("\t" ^ level, st) end end nested(subtype)end
julia> @code_warntype showtypetree(Number)Variables: #self#::#showtypetree subtype::Type{Number} level::Core.Box nested::Core.Box
Body: begin level::Core.Box = $(Expr(:new, :(Core.Box))) nested::Core.Box = $(Expr(:new, :(Core.Box))) SSAValue(0) = Main.Void (Core.setfield!)(level::Core.Box,:contents,0)::Int64 # line 3: SSAValue(1) = $(Expr(:new, :(Main.#nested#2), :(level), :(nested))) (Core.setfield!)(nested::Core.Box,:contents,SSAValue(1))::#nested#2 # line 16: return (Base.convert)(SSAValue(0),((Core.getfield)(nested::Core.Box,:contents)::Any)(subtype::Type{Number})::Any)::Void end::Void