Skip to content

Commit 4c4aaff

Browse files
authored
Change arguments to (internal) show_tuple_as_call to kwargs (#39020)
Forward port from #37849 to reduce the number of unrelated changes in that PR. The argument list here was simply getting unwieldy. The new `hasfirst` argument isn't yet used in this PR, but will be used in #37849.
1 parent a2b6426 commit 4c4aaff

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

base/show.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ function show_mi(io::IO, l::Core.MethodInstance, from_stackframe::Bool=false)
994994
show(io, def)
995995
else
996996
print(io, "MethodInstance for ")
997-
show_tuple_as_call(io, def.name, l.specTypes, false, nothing, nothing, true)
997+
show_tuple_as_call(io, def.name, l.specTypes; qualified=true)
998998
end
999999
else
10001000
print(io, "Toplevel MethodInstance thunk")
@@ -1024,7 +1024,7 @@ function show(io::IO, mi_info::Core.Compiler.Timings.InferenceFrameInfo)
10241024
else
10251025
print(io, "InferenceFrameInfo for ")
10261026
argnames = [isa(a, Core.Const) ? (isa(a.val, Type) ? "" : a.val) : "" for a in mi_info.slottypes[1:mi_info.nargs]]
1027-
show_tuple_as_call(io, def.name, mi.specTypes, false, nothing, argnames, true)
1027+
show_tuple_as_call(io, def.name, mi.specTypes; argnames, qualified=true)
10281028
end
10291029
else
10301030
linetable = mi.uninferred.linetable
@@ -2176,7 +2176,9 @@ function print_within_stacktrace(io, s...; color=:normal, bold=false)
21762176
end
21772177
end
21782178

2179-
function show_tuple_as_call(io::IO, name::Symbol, sig::Type, demangle=false, kwargs=nothing, argnames=nothing, qualified=false)
2179+
function show_tuple_as_call(io::IO, name::Symbol, sig::Type;
2180+
demangle=false, kwargs=nothing, argnames=nothing,
2181+
qualified=false, hasfirst=true)
21802182
# print a method signature tuple for a lambda definition
21812183
if sig === Tuple
21822184
print(io, demangle ? demangle_function_name(name) : name, "(...)")
@@ -2189,12 +2191,16 @@ function show_tuple_as_call(io::IO, name::Symbol, sig::Type, demangle=false, kwa
21892191
env_io = IOContext(env_io, :unionall_env => sig.var)
21902192
sig = sig.body
21912193
end
2194+
n = 1
21922195
sig = (sig::DataType).parameters
2193-
show_signature_function(env_io, sig[1], demangle, "", false, qualified)
2196+
if hasfirst
2197+
show_signature_function(env_io, sig[1], demangle, "", false, qualified)
2198+
n += 1
2199+
end
21942200
first = true
21952201
print_within_stacktrace(io, "(", bold=true)
21962202
show_argnames = argnames !== nothing && length(argnames) == length(sig)
2197-
for i = 2:length(sig) # fixme (iter): `eachindex` with offset?
2203+
for i = n:length(sig) # fixme (iter): `eachindex` with offset?
21982204
first || print(io, ", ")
21992205
first = false
22002206
if show_argnames

base/stacktraces.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,12 @@ function show_spec_linfo(io::IO, frame::StackFrame)
236236
kwnames[i] = Symbol(str[1:end-3])
237237
end
238238
end
239-
Base.show_tuple_as_call(io, def.name, pos_sig, true, zip(kwnames, kwarg_types), argnames[def.nkw+2:end])
239+
Base.show_tuple_as_call(io, def.name, pos_sig;
240+
demangle=true,
241+
kwargs=zip(kwnames, kwarg_types),
242+
argnames=argnames[def.nkw+2:end])
240243
else
241-
Base.show_tuple_as_call(io, def.name, sig, true, nothing, argnames)
244+
Base.show_tuple_as_call(io, def.name, sig; demangle=true, argnames)
242245
end
243246
else
244247
Base.show_mi(io, linfo, true)

0 commit comments

Comments
 (0)