Skip to content

Commit 5f3a380

Browse files
committed
minor refactors on REPLCompletions.jl
Those I found while working on #52952.
1 parent 19f1c75 commit 5f3a380

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

stdlib/REPL/src/REPLCompletions.jl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ function complete_any_methods(ex_org::Expr, callee_module::Module, context_modul
812812
isa(c, TextCompletion) && return false
813813
isa(c, MethodCompletion) || return true
814814
sig = Base.unwrap_unionall(c.method.sig)::DataType
815-
return !all(T -> T === Any || T === Vararg{Any}, sig.parameters[2:end])
815+
return !all(@nospecialize(T) -> T === Any || T === Vararg{Any}, sig.parameters[2:end])
816816
end
817817
end
818818

@@ -1439,7 +1439,7 @@ function shell_completions(string, pos)
14391439
r = pos+1:pos
14401440
paths, dir, success = complete_path("", use_envpath=false, shell_escape=true)
14411441
return paths, r, success
1442-
elseif all(arg -> arg isa AbstractString, ex.args)
1442+
elseif all(@nospecialize(arg) -> arg isa AbstractString, ex.args)
14431443
# Join these and treat this as a path
14441444
path::String = join(ex.args)
14451445
r = last_arg_start:pos
@@ -1518,22 +1518,28 @@ function UndefVarError_hint(io::IO, ex::UndefVarError)
15181518
else
15191519
scope = undef
15201520
end
1521-
warnfor(m, var) = Base.isbindingresolved(m, var) && (Base.isexported(m, var) || Base.ispublic(m, var)) && (print(io, "\nHint: a global variable of this name also exists in $m."); true)
1522-
if scope !== Base && !warnfor(Base, var)
1521+
if scope !== Base && !_UndefVarError_warnfor(Base, var)
15231522
warned = false
15241523
for m in Base.loaded_modules_order
15251524
m === Core && continue
15261525
m === Base && continue
15271526
m === Main && continue
15281527
m === scope && continue
1529-
warned = warnfor(m, var) || warned
1528+
warned = _UndefVarError_warnfor(m, var) || warned
15301529
end
1531-
warned = warned || warnfor(Core, var)
1532-
warned = warned || warnfor(Main, var)
1530+
warned = warned || _UndefVarError_warnfor(Core, var)
1531+
warned = warned || _UndefVarError_warnfor(Main, var)
15331532
end
15341533
nothing
15351534
end
15361535

1536+
function _UndefVarError_warnfor(io::IO, m::Module, var::Symbol)
1537+
Base.isbindingresolved(m, var) || return false
1538+
(Base.isexported(m, var) || Base.ispublic(m, var)) || return false
1539+
print(io, "\nHint: a global variable of this name also exists in $m.")
1540+
return true
1541+
end
1542+
15371543
function __init__()
15381544
Base.Experimental.register_error_hint(UndefVarError_hint, UndefVarError)
15391545
COMPLETION_WORLD[] = Base.get_world_counter()

0 commit comments

Comments
 (0)