Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add some helpful type information to Base and REPLCompletions #34596

Merged
merged 1 commit into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1485,7 +1485,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 @@ -1497,6 +1497,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