Skip to content

Commit

Permalink
remove InteractiveUtils.dumptype (#42093)
Browse files Browse the repository at this point in the history
It was broken (`TypeName.abstract`) is not defined anymore, so clearly has
no users nor tests and can simply be deleted at this point.
  • Loading branch information
vtjnash committed Sep 4, 2021
1 parent 027071f commit c3d2903
Showing 1 changed file with 0 additions and 68 deletions.
68 changes: 0 additions & 68 deletions stdlib/InteractiveUtils/src/InteractiveUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -279,74 +279,6 @@ function supertypes(T::Type)
return S === T ? (T,) : (T, supertypes(S)...)
end

# dumptype is for displaying abstract type hierarchies,
# based on Jameson Nash's typetree.jl in https://github.com/JuliaArchive/Examples
function dumptype(io::IO, @nospecialize(x), n::Int, indent)
print(io, x)
n == 0 && return # too deeply nested
isa(x, DataType) && x.name.abstract && dumpsubtypes(io, x, Main, n, indent)
nothing
end

directsubtype(a::DataType, b::DataType) = supertype(a).name === b.name
directsubtype(a::UnionAll, b::DataType) = directsubtype(a.body, b)
directsubtype(a::Union, b::DataType) = directsubtype(a.a, b) || directsubtype(a.b, b)
# Fallback to handle TypeVar's
directsubtype(a, b::DataType) = false
function dumpsubtypes(io::IO, x::DataType, m::Module, n::Int, indent)
for s in names(m, all = true)
if isdefined(m, s) && !isdeprecated(m, s)
t = getfield(m, s)
if t === x || t === m
continue
elseif isa(t, Module) && nameof(t) === s && parentmodule(t) === m
# recurse into primary module bindings
dumpsubtypes(io, x, t, n, indent)
elseif isa(t, UnionAll) && directsubtype(t::UnionAll, x)
dt = unwrap_unionall(t)
println(io)
if isa(dt, DataType) && dt.name.wrapper === t
# primary type binding
print(io, indent, " ")
dumptype(io, dt, n - 1, string(indent, " "))
else
# aliases to types
print(io, indent, " ", m, ".", s, "{")
tvar_io::IOContext = io
tp = t
while true
show(tvar_io, tp.var)
tvar_io = IOContext(tvar_io, :unionall_env => tp.var)
tp = tp.body
if isa(tp, UnionAll)
print(io, ", ")
else
print(io, "} = ")
break
end
end
show(tvar_io, tp)
end
elseif isa(t, Union) && directsubtype(t::Union, x)
println(io)
print(io, indent, " ", m, ".", s, " = ", t)
elseif isa(t, DataType) && directsubtype(t::DataType, x)
println(io)
if t.name.module !== m || t.name.name != s
# aliases to types
print(io, indent, " ", m, ".", s, " = ")
show(io, t)
else
# primary type binding
print(io, indent, " ")
dumptype(io, t, n - 1, string(indent, " "))
end
end
end
end
nothing
end

# TODO: @deprecate peakflops to LinearAlgebra
export peakflops
"""
Expand Down

0 comments on commit c3d2903

Please sign in to comment.