Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make compact type alias output more compact #39256

Merged
merged 1 commit into from
Jan 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
make compact type alias output more compact
  • Loading branch information
JeffBezanson committed Jan 28, 2021
commit 0db987728dd001423f05aeb2bf0650beeeefbd45
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)
JeffBezanson marked this conversation as resolved.
Show resolved Hide resolved
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