Skip to content

Commit

Permalink
make compact type alias output more compact (#39256)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jan 29, 2021
1 parent 3ee63a6 commit c8cc69b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -789,15 +789,19 @@ function show_unionaliases(io::IO, x::Union)
end

function show(io::IO, ::MIME"text/plain", @nospecialize(x::Type))
show(io, x)
if !print_without_params(x) && get(io, :compact, true)
if !print_without_params(x)
properx = makeproper(io, x)
if make_typealias(properx) !== nothing || (unwrap_unionall(x) isa Union && x <: make_typealiases(properx)[2])
print(io, " (alias for ")
show(IOContext(io, :compact => false), x)
print(io, ")")
show(IOContext(io, :compact => true), x)
if !(get(io, :compact, false)::Bool)
print(io, " (alias for ")
show(IOContext(io, :compact => false), x)
print(io, ")")
end
return
end
end
show(io, x)
# give a helpful hint for function types
if x isa DataType && x !== UnionAll && !(get(io, :compact, false)::Bool)
tn = x.name::Core.TypeName
Expand Down

0 comments on commit c8cc69b

Please sign in to comment.