Skip to content

Commit 02272f0

Browse files
authored
allow show_tuple_as_call to be used for abstract call signature (#50398)
1 parent ce1b420 commit 02272f0

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

base/show.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ function show(io::IO, ::MIME"text/plain", r::LinRange)
2323
print_range(io, r)
2424
end
2525

26-
function _isself(@nospecialize(ft))
27-
name = ft.name.mt.name
26+
function _isself(ft::DataType)
27+
ftname = ft.name
28+
isdefined(ftname, :mt) || return false
29+
name = ftname.mt.name
2830
mod = parentmodule(ft) # NOTE: not necessarily the same as ft.name.mt.module
2931
return isdefined(mod, name) && ft == typeof(getfield(mod, name))
3032
end
@@ -2128,7 +2130,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
21282130

21292131
# comparison (i.e. "x < y < z")
21302132
elseif head === :comparison && nargs >= 3 && (nargs&1==1)
2131-
comp_prec = minimum(operator_precedence, args[2:2:end])
2133+
comp_prec = minimum(operator_precedence, args[2:2:end]; init=typemax(Int))
21322134
if comp_prec <= prec
21332135
show_enclosed_list(io, '(', args, " ", ')', indent, comp_prec, quote_level)
21342136
else

test/show.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,3 +2630,8 @@ end
26302630
ir = Core.Compiler.complete(compact)
26312631
verify_display(ir)
26322632
end
2633+
2634+
let buf = IOBuffer()
2635+
Base.show_tuple_as_call(buf, Symbol(""), Tuple{Function,Any})
2636+
@test String(take!(buf)) == "(::Function)(::Any)"
2637+
end

0 commit comments

Comments
 (0)