Skip to content

Commit cced577

Browse files
authored
add some helpful type information to Base and REPLCompletions (#34596)
fixes #34098
1 parent 10f9531 commit cced577

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

base/client.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ using ..Base
427427
# include(fname::AbstractString) = Main.Base.include(Main, fname)
428428
function include(fname::AbstractString)
429429
mod = Main
430-
isa(fname, String) || (fname = Base.convert(String, fname))
430+
isa(fname, String) || (fname = Base.convert(String, fname)::String)
431431
path, prev = Base._include_dependency(mod, fname)
432432
for callback in Base.include_callbacks # to preserve order, must come before Core.include
433433
Base.invokelatest(callback, mod, path)

base/loading.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -1086,8 +1086,8 @@ include_string(m::Module, txt::AbstractString, fname::AbstractString="string") =
10861086

10871087
function source_path(default::Union{AbstractString,Nothing}="")
10881088
s = current_task().storage
1089-
if s !== nothing && haskey(s, :SOURCE_PATH)
1090-
return s[:SOURCE_PATH]
1089+
if s !== nothing && haskey(s::IdDict{Any,Any}, :SOURCE_PATH)
1090+
return s[:SOURCE_PATH]::Union{Nothing,String}
10911091
end
10921092
return default
10931093
end
@@ -1487,7 +1487,7 @@ Alternatively see [`PROGRAM_FILE`](@ref).
14871487
"""
14881488
macro __FILE__()
14891489
__source__.file === nothing && return nothing
1490-
return String(__source__.file)
1490+
return String(__source__.file::Symbol)
14911491
end
14921492

14931493
"""
@@ -1499,6 +1499,6 @@ Return the current working directory if run from a REPL or if evaluated by `juli
14991499
"""
15001500
macro __DIR__()
15011501
__source__.file === nothing && return nothing
1502-
_dirname = dirname(String(__source__.file))
1502+
_dirname = dirname(String(__source__.file::Symbol))
15031503
return isempty(_dirname) ? pwd() : abspath(_dirname)
15041504
end

base/logging.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ end
204204
macro _sourceinfo()
205205
esc(quote
206206
(__module__,
207-
__source__.file === nothing ? "?" : String(__source__.file),
207+
__source__.file === nothing ? "?" : String(__source__.file::Symbol),
208208
__source__.line)
209209
end)
210210
end

stdlib/REPL/src/REPLCompletions.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ function complete_path(path::AbstractString, pos; use_envpath=false, shell_escap
266266
end
267267
end
268268

269-
matchList = Completion[PathCompletion(shell_escape ? replace(s, r"\s" => s"\\\0") : s) for s in matches]
269+
matchList = PathCompletion[PathCompletion(shell_escape ? replace(s, r"\s" => s"\\\0") : s) for s in matches]
270270
startpos = pos - lastindex(prefix) + 1 - count(isequal(' '), prefix)
271271
# The pos - lastindex(prefix) + 1 is correct due to `lastindex(prefix)-lastindex(prefix)==0`,
272272
# hence we need to add one to get the first index. This is also correct when considering
@@ -544,7 +544,7 @@ end
544544

545545
# This needs to be a separate non-inlined function, see #19441
546546
@noinline function find_dict_matches(identifier, partial_key)
547-
matches = []
547+
matches = String[]
548548
for key in keys(identifier)
549549
rkey = repr(key)
550550
startswith(rkey,partial_key) && push!(matches,rkey)

0 commit comments

Comments
 (0)