Skip to content

Commit aba3834

Browse files
vtjnashKristofferC
authored andcommitted
fix showing types after removing using Core (#58773)
PR #57357 changed the default using list, but only changed some of the places where the `show` code handled that. This led to duplicate (confusing) printing, since both Core. and Base. prefixes are dropped. Fix #58772 (cherry picked from commit 089810c)
1 parent 5ae9342 commit aba3834

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

base/show.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ function active_module()
531531
return invokelatest(active_module, active_repl)::Module
532532
end
533533

534-
module UsesCoreAndBaseOnly
534+
module UsesBaseOnly
535535
end
536536

537537
function show_function(io::IO, f::Function, compact::Bool, fallback::Function)
@@ -543,8 +543,8 @@ function show_function(io::IO, f::Function, compact::Bool, fallback::Function)
543543
elseif isdefined(fname, :module) && isdefinedglobal(fname.module, fname.singletonname) && isconst(fname.module, fname.singletonname) &&
544544
getglobal(fname.module, fname.singletonname) === f
545545
# this used to call the removed internal function `is_exported_from_stdlib`, which effectively
546-
# just checked for exports from Core and Base.
547-
mod = get(io, :module, UsesCoreAndBaseOnly)
546+
# just checked for exports from Base.
547+
mod = get(io, :module, UsesBaseOnly)
548548
if !(isvisible(fname.singletonname, fname.module, mod) || fname.module === mod)
549549
print(io, fname.module, ".")
550550
end
@@ -818,7 +818,7 @@ function make_typealiases(@nospecialize(x::Type))
818818
Any === x && return aliases, Union{}
819819
x <: Tuple && return aliases, Union{}
820820
mods = modulesof!(Set{Module}(), x)
821-
Core in mods && push!(mods, Base)
821+
replace!(mods, Core=>Base)
822822
vars = Dict{Symbol,TypeVar}()
823823
xenv = UnionAll[]
824824
each = Any[]
@@ -836,7 +836,7 @@ function make_typealiases(@nospecialize(x::Type))
836836
ti === Union{} && continue
837837
# make sure this alias wasn't from an unrelated part of the Union
838838
mod2 = modulesof!(Set{Module}(), alias)
839-
mod in mod2 || (mod === Base && Core in mods) || continue
839+
mod in mod2 || (mod === Base && Core in mod2) || continue
840840
env = env::SimpleVector
841841
applied = alias
842842
if !isempty(env)

test/show.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,6 +2458,7 @@ end
24582458
@test string(Union{M37012.SimpleU, Nothing, T} where T) == "Union{Nothing, $(curmod_prefix)M37012.SimpleU, T} where T"
24592459
@test string(Union{AbstractVector{T}, T} where T) == "Union{AbstractVector{T}, T} where T"
24602460
@test string(Union{AbstractVector, T} where T) == "Union{AbstractVector, T} where T"
2461+
@test string(Union{Array, Memory}) == "Union{Array, Memory}"
24612462

24622463
@test sprint(show, :(./)) == ":((./))"
24632464
@test sprint(show, :((.|).(.&, b))) == ":((.|).((.&), b))"

0 commit comments

Comments
 (0)