From cced577b79316ea38482d84b69e7be9666d14041 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Mon, 3 Feb 2020 14:41:05 -0500 Subject: [PATCH] add some helpful type information to Base and REPLCompletions (#34596) fixes #34098 --- base/client.jl | 2 +- base/loading.jl | 8 ++++---- base/logging.jl | 2 +- stdlib/REPL/src/REPLCompletions.jl | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/base/client.jl b/base/client.jl index a6b07aadde5a7..5341c465bf9bb 100644 --- a/base/client.jl +++ b/base/client.jl @@ -427,7 +427,7 @@ using ..Base # include(fname::AbstractString) = Main.Base.include(Main, fname) function include(fname::AbstractString) mod = Main - isa(fname, String) || (fname = Base.convert(String, fname)) + isa(fname, String) || (fname = Base.convert(String, fname)::String) path, prev = Base._include_dependency(mod, fname) for callback in Base.include_callbacks # to preserve order, must come before Core.include Base.invokelatest(callback, mod, path) diff --git a/base/loading.jl b/base/loading.jl index 1de844128d547..cc4153e9a31e6 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1086,8 +1086,8 @@ include_string(m::Module, txt::AbstractString, fname::AbstractString="string") = function source_path(default::Union{AbstractString,Nothing}="") s = current_task().storage - if s !== nothing && haskey(s, :SOURCE_PATH) - return s[:SOURCE_PATH] + if s !== nothing && haskey(s::IdDict{Any,Any}, :SOURCE_PATH) + return s[:SOURCE_PATH]::Union{Nothing,String} end return default end @@ -1487,7 +1487,7 @@ Alternatively see [`PROGRAM_FILE`](@ref). """ macro __FILE__() __source__.file === nothing && return nothing - return String(__source__.file) + return String(__source__.file::Symbol) end """ @@ -1499,6 +1499,6 @@ Return the current working directory if run from a REPL or if evaluated by `juli """ macro __DIR__() __source__.file === nothing && return nothing - _dirname = dirname(String(__source__.file)) + _dirname = dirname(String(__source__.file::Symbol)) return isempty(_dirname) ? pwd() : abspath(_dirname) end diff --git a/base/logging.jl b/base/logging.jl index a9dd022cf8105..517bcd3e0d5b4 100644 --- a/base/logging.jl +++ b/base/logging.jl @@ -204,7 +204,7 @@ end macro _sourceinfo() esc(quote (__module__, - __source__.file === nothing ? "?" : String(__source__.file), + __source__.file === nothing ? "?" : String(__source__.file::Symbol), __source__.line) end) end diff --git a/stdlib/REPL/src/REPLCompletions.jl b/stdlib/REPL/src/REPLCompletions.jl index 3af98d6e53e8f..b31b41f2405bf 100644 --- a/stdlib/REPL/src/REPLCompletions.jl +++ b/stdlib/REPL/src/REPLCompletions.jl @@ -266,7 +266,7 @@ function complete_path(path::AbstractString, pos; use_envpath=false, shell_escap end end - matchList = Completion[PathCompletion(shell_escape ? replace(s, r"\s" => s"\\\0") : s) for s in matches] + matchList = PathCompletion[PathCompletion(shell_escape ? replace(s, r"\s" => s"\\\0") : s) for s in matches] startpos = pos - lastindex(prefix) + 1 - count(isequal(' '), prefix) # The pos - lastindex(prefix) + 1 is correct due to `lastindex(prefix)-lastindex(prefix)==0`, # hence we need to add one to get the first index. This is also correct when considering @@ -544,7 +544,7 @@ end # This needs to be a separate non-inlined function, see #19441 @noinline function find_dict_matches(identifier, partial_key) - matches = [] + matches = String[] for key in keys(identifier) rkey = repr(key) startswith(rkey,partial_key) && push!(matches,rkey)