Skip to content

Commit 88535e7

Browse files
authored
Improve inference in Method display and others (#38343)
1 parent eb7618d commit 88535e7

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

base/error.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ exception will continue propagation as if it had not been caught.
5757
described in [`catch_stack`](@ref).
5858
"""
5959
rethrow() = ccall(:jl_rethrow, Bottom, ())
60-
rethrow(e) = ccall(:jl_rethrow_other, Bottom, (Any,), e)
60+
rethrow(@nospecialize(e)) = ccall(:jl_rethrow_other, Bottom, (Any,), e)
6161

6262
struct InterpreterIP
6363
code::Union{CodeInfo,Core.MethodInstance,Nothing}

base/methodshow.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function kwarg_decl(m::Method, kwtype = nothing)
9090
kwli = ccall(:jl_methtable_lookup, Any, (Any, Any, UInt), kwtype.name.mt, sig, get_world_counter())
9191
if kwli !== nothing
9292
kwli = kwli::Method
93-
slotnames = ccall(:jl_uncompress_argnames, Vector{Any}, (Any,), kwli.slot_syms)
93+
slotnames = ccall(:jl_uncompress_argnames, Vector{Symbol}, (Any,), kwli.slot_syms)
9494
kws = filter(x -> !(x === empty_sym || '#' in string(x)), slotnames[(kwli.nargs + 1):end])
9595
# ensure the kwarg... is always printed last. The order of the arguments are not
9696
# necessarily the same as defined in the function
@@ -102,7 +102,7 @@ function kwarg_decl(m::Method, kwtype = nothing)
102102
return kws
103103
end
104104
end
105-
return Any[]
105+
return Symbol[]
106106
end
107107

108108
function show_method_params(io::IO, tv)
@@ -152,7 +152,7 @@ function updated_methodloc(m::Method)::Tuple{String, Int32}
152152
end
153153
end
154154
file = fixup_stdlib_path(string(file))
155-
return file, line
155+
return file, Int32(line)
156156
end
157157

158158
functionloc(m::Core.MethodInstance) = functionloc(m.def)

base/strings/util.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function startswith(a::AbstractString, b::AbstractString)
2222
a, b = Iterators.Stateful(a), Iterators.Stateful(b)
2323
all(splat(==), zip(a, b)) && isempty(b)
2424
end
25-
startswith(str::AbstractString, chars::Chars) = !isempty(str) && first(str) in chars
25+
startswith(str::AbstractString, chars::Chars) = !isempty(str) && first(str)::AbstractChar in chars
2626

2727
"""
2828
endswith(s::AbstractString, suffix::AbstractString)

stdlib/REPL/src/docview.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,15 @@ end
129129
function _trimdocs(md::Markdown.MD, brief::Bool)
130130
content, trimmed = [], false
131131
for c in md.content
132-
if isa(c, Markdown.Header{1}) && isa(c.text, AbstractArray) &&
133-
!isempty(c.text) && isa(c.text[1], AbstractString) &&
134-
lowercase(c.text[1]) ("extended help",
135-
"extended documentation",
136-
"extended docs")
137-
trimmed = true
138-
break
132+
if isa(c, Markdown.Header{1}) && isa(c.text, AbstractArray) && !isempty(c.text)
133+
item = c.text[1]
134+
if isa(item, AbstractString) &&
135+
lowercase(item) ("extended help",
136+
"extended documentation",
137+
"extended docs")
138+
trimmed = true
139+
break
140+
end
139141
end
140142
c, trm = _trimdocs(c, brief)
141143
trimmed |= trm

0 commit comments

Comments
 (0)