Skip to content

Commit 089810c

Browse files
authored
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
1 parent 098a4f8 commit 089810c

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
@@ -538,7 +538,7 @@ function active_module()
538538
return invokelatest(active_module, active_repl)::Module
539539
end
540540

541-
module UsesCoreAndBaseOnly
541+
module UsesBaseOnly
542542
end
543543

544544
function show_function(io::IO, f::Function, compact::Bool, fallback::Function)
@@ -550,8 +550,8 @@ function show_function(io::IO, f::Function, compact::Bool, fallback::Function)
550550
elseif isdefined(fname, :module) && isdefinedglobal(fname.module, fname.singletonname) && isconst(fname.module, fname.singletonname) &&
551551
getglobal(fname.module, fname.singletonname) === f
552552
# this used to call the removed internal function `is_exported_from_stdlib`, which effectively
553-
# just checked for exports from Core and Base.
554-
mod = get(io, :module, UsesCoreAndBaseOnly)
553+
# just checked for exports from Base.
554+
mod = get(io, :module, UsesBaseOnly)
555555
if !(isvisible(fname.singletonname, fname.module, mod) || fname.module === mod)
556556
print(io, fname.module, ".")
557557
end
@@ -825,7 +825,7 @@ function make_typealiases(@nospecialize(x::Type))
825825
Any === x && return aliases, Union{}
826826
x <: Tuple && return aliases, Union{}
827827
mods = modulesof!(Set{Module}(), x)
828-
Core in mods && push!(mods, Base)
828+
replace!(mods, Core=>Base)
829829
vars = Dict{Symbol,TypeVar}()
830830
xenv = UnionAll[]
831831
each = Any[]
@@ -843,7 +843,7 @@ function make_typealiases(@nospecialize(x::Type))
843843
ti === Union{} && continue
844844
# make sure this alias wasn't from an unrelated part of the Union
845845
mod2 = modulesof!(Set{Module}(), alias)
846-
mod in mod2 || (mod === Base && Core in mods) || continue
846+
mod in mod2 || (mod === Base && Core in mod2) || continue
847847
env = env::SimpleVector
848848
applied = alias
849849
if !isempty(env)

test/show.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,6 +2488,7 @@ end
24882488
@test string(Union{M37012.SimpleU, Nothing, T} where T) == "Union{Nothing, $(curmod_prefix)M37012.SimpleU, T} where T"
24892489
@test string(Union{AbstractVector{T}, T} where T) == "Union{AbstractVector{T}, T} where T"
24902490
@test string(Union{AbstractVector, T} where T) == "Union{AbstractVector, T} where T"
2491+
@test string(Union{Array, Memory}) == "Union{Array, Memory}"
24912492

24922493
@test sprint(show, :(./)) == ":((./))"
24932494
@test sprint(show, :((.|).(.&, b))) == ":((.|).((.&), b))"

0 commit comments

Comments
 (0)