@@ -514,24 +514,16 @@ function _show_default(io::IO, @nospecialize(x))
514514end
515515
516516function active_module ()
517- REPL = REPL_MODULE_REF[]
518- REPL === Base && return Main
519- return invokelatest (REPL. active_module):: Module
517+ if ccall (:jl_is_in_pure_context , Bool, ())
518+ error (" active_module() should not be called from a pure context" )
519+ end
520+ if ! @isdefined (active_repl) || active_repl === nothing
521+ return Main
522+ end
523+ return invokelatest (active_module, active_repl):: Module
520524end
521525
522- # Check if a particular symbol is exported from a standard library module
523- function is_exported_from_stdlib (name:: Symbol , mod:: Module )
524- ! isdefined (mod, name) && return false
525- orig = getfield (mod, name)
526- while ! (mod === Base || mod === Core)
527- activemod = active_module ()
528- parent = parentmodule (mod)
529- if mod === activemod || mod === parent || parent === activemod
530- return false
531- end
532- mod = parent
533- end
534- return isexported (mod, name) && isdefined (mod, name) && ! isdeprecated (mod, name) && getfield (mod, name) === orig
526+ module UsesCoreAndBaseOnly
535527end
536528
537529function show_function (io:: IO , f:: Function , compact:: Bool , fallback:: Function )
@@ -544,13 +536,13 @@ function show_function(io::IO, f::Function, compact::Bool, fallback::Function)
544536 print (io, mt. name)
545537 elseif isdefined (mt, :module ) && isdefined (mt. module, mt. name) &&
546538 getfield (mt. module, mt. name) === f
547- mod = active_module ()
548- if is_exported_from_stdlib (mt . name, mt . module) || mt . module === mod
549- show_sym (io, mt . name )
550- else
539+ # this used to call the removed internal function `is_exported_from_stdlib`, which effectively
540+ # just checked for exports from Core and Base.
541+ mod = get (io, :module , UsesCoreAndBaseOnly )
542+ if ! ( isvisible (mt . name, mt . module, mod) || mt . module === mod)
551543 print (io, mt. module, " ." )
552- show_sym (io, mt. name)
553544 end
545+ show_sym (io, mt. name)
554546 else
555547 fallback (io, f)
556548 end
737729function show_typealias (io:: IO , name:: GlobalRef , x:: Type , env:: SimpleVector , wheres:: Vector )
738730 if ! (get (io, :compact , false ):: Bool )
739731 # Print module prefix unless alias is visible from module passed to
740- # IOContext. If :module is not set, default to Main (or current active module) .
732+ # IOContext. If :module is not set, default to Main.
741733 # nothing can be used to force printing prefix.
742- from = get (io, :module , active_module () )
734+ from = get (io, :module , Main )
743735 if (from === nothing || ! isvisible (name. name, name. mod, from))
744736 show (io, name. mod)
745737 print (io, " ." )
@@ -1053,9 +1045,9 @@ function show_type_name(io::IO, tn::Core.TypeName)
10531045 quo = false
10541046 if ! (get (io, :compact , false ):: Bool )
10551047 # Print module prefix unless type is visible from module passed to
1056- # IOContext If :module is not set, default to Main (or current active module) .
1048+ # IOContext If :module is not set, default to Main.
10571049 # nothing can be used to force printing prefix
1058- from = get (io, :module , active_module () )
1050+ from = get (io, :module , Main )
10591051 if isdefined (tn, :module ) && (from === nothing || ! isvisible (sym, tn. module, from:: Module ))
10601052 show (io, tn. module)
10611053 print (io, " ." )
@@ -2535,7 +2527,7 @@ function show_signature_function(io::IO, @nospecialize(ft), demangle=false, farg
25352527 uw = unwrap_unionall (ft)
25362528 if ft <: Function && isa (uw, DataType) && isempty (uw. parameters) && _isself (uw)
25372529 uwmod = parentmodule (uw)
2538- if qualified && ! is_exported_from_stdlib ( uw. name. mt. name, uwmod ) && uwmod != = Main
2530+ if qualified && ! isexported (uwmod, uw. name. mt. name) && uwmod != = Main
25392531 print_within_stacktrace (io, uwmod, ' .' , bold= true )
25402532 end
25412533 s = sprint (show_sym, (demangle ? demangle_function_name : identity)(uw. name. mt. name), context= io)
0 commit comments