Skip to content

Commit 2c85595

Browse files
authored
Merge pull request #22586 from JuliaLang/jb/methodhtml
fix bug in HTML showing of method table of function with parameters
2 parents f62f32a + 2f1d30d commit 2c85595

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

base/methodshow.jl

+8-6
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,16 @@ end
9797
function show(io::IO, m::Method; kwtype::Nullable{DataType}=Nullable{DataType}())
9898
tv, decls, file, line = arg_decl_parts(m)
9999
sig = unwrap_unionall(m.sig)
100-
ft = unwrap_unionall(sig.parameters[1])
100+
ft0 = sig.parameters[1]
101+
ft = unwrap_unionall(ft0)
101102
d1 = decls[1]
102103
if sig === Tuple
103104
print(io, m.name)
104105
decls = Any[(), ("...", "")]
105-
elseif ft <: Function &&
106+
elseif ft <: Function && isa(ft, DataType) &&
106107
isdefined(ft.name.module, ft.name.mt.name) &&
107108
# TODO: more accurate test? (tn.name === "#" name)
108-
ft == typeof(getfield(ft.name.module, ft.name.mt.name))
109+
ft0 === typeof(getfield(ft.name.module, ft.name.mt.name))
109110
print(io, ft.name.mt.name)
110111
elseif isa(ft, DataType) && ft.name === Type.body.name && isleaftype(ft)
111112
f = ft.parameters[1]
@@ -226,11 +227,12 @@ end
226227
function show(io::IO, ::MIME"text/html", m::Method; kwtype::Nullable{DataType}=Nullable{DataType}())
227228
tv, decls, file, line = arg_decl_parts(m)
228229
sig = unwrap_unionall(m.sig)
229-
ft = sig.parameters[1]
230+
ft0 = sig.parameters[1]
231+
ft = unwrap_unionall(ft0)
230232
d1 = decls[1]
231-
if ft <: Function &&
233+
if ft <: Function && isa(ft, DataType) &&
232234
isdefined(ft.name.module, ft.name.mt.name) &&
233-
ft == typeof(getfield(ft.name.module, ft.name.mt.name))
235+
ft0 === typeof(getfield(ft.name.module, ft.name.mt.name))
234236
print(io, ft.name.mt.name)
235237
elseif isa(ft, DataType) && ft.name === Type.body.name && isleaftype(ft)
236238
f = ft.parameters[1]

test/show.jl

+11-1
Original file line numberDiff line numberDiff line change
@@ -778,4 +778,14 @@ let fname = tempname()
778778
finally
779779
rm(fname, force=true)
780780
end
781-
end
781+
end
782+
783+
struct f_with_params{t} <: Function
784+
end
785+
786+
(::f_with_params)(x) = 2x
787+
788+
let io = IOBuffer()
789+
show(io, MIME"text/html"(), f_with_params.body.name.mt)
790+
@test contains(String(take!(io)), "f_with_params")
791+
end

0 commit comments

Comments
 (0)