Skip to content

Commit

Permalink
add some helpful type information to Base and REPLCompletions (#34596)
Browse files Browse the repository at this point in the history
fixes #34098
  • Loading branch information
JeffBezanson authored Feb 3, 2020
1 parent 10f9531 commit cced577
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

"""
Expand All @@ -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
2 changes: 1 addition & 1 deletion base/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cced577

Please sign in to comment.