Skip to content

Commit

Permalink
Merge pull request #22586 from JuliaLang/jb/methodhtml
Browse files Browse the repository at this point in the history
fix bug in HTML showing of method table of function with parameters

Ref #22586
(cherry picked from commit 2c85595)
  • Loading branch information
JeffBezanson authored and ararslan committed Sep 11, 2017
1 parent 883e08e commit d711597
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 8 additions & 6 deletions base/methodshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,16 @@ end
function show(io::IO, m::Method; kwtype::Nullable{DataType}=Nullable{DataType}())
tv, decls, file, line = arg_decl_parts(m)
sig = unwrap_unionall(m.sig)
ft = unwrap_unionall(sig.parameters[1])
ft0 = sig.parameters[1]
ft = unwrap_unionall(ft0)
d1 = decls[1]
if sig === Tuple
print(io, m.name)
decls = Any[(), ("...", "")]
elseif ft <: Function &&
elseif ft <: Function && isa(ft, DataType) &&
isdefined(ft.name.module, ft.name.mt.name) &&
# TODO: more accurate test? (tn.name === "#" name)
ft == typeof(getfield(ft.name.module, ft.name.mt.name))
ft0 === typeof(getfield(ft.name.module, ft.name.mt.name))
print(io, ft.name.mt.name)
elseif isa(ft, DataType) && ft.name === Type.body.name && isleaftype(ft)
f = ft.parameters[1]
Expand Down Expand Up @@ -222,11 +223,12 @@ end
function show(io::IO, ::MIME"text/html", m::Method; kwtype::Nullable{DataType}=Nullable{DataType}())
tv, decls, file, line = arg_decl_parts(m)
sig = unwrap_unionall(m.sig)
ft = sig.parameters[1]
ft0 = sig.parameters[1]
ft = unwrap_unionall(ft0)
d1 = decls[1]
if ft <: Function &&
if ft <: Function && isa(ft, DataType) &&
isdefined(ft.name.module, ft.name.mt.name) &&
ft == typeof(getfield(ft.name.module, ft.name.mt.name))
ft0 === typeof(getfield(ft.name.module, ft.name.mt.name))
print(io, ft.name.mt.name)
elseif isa(ft, DataType) && ft.name === Type.body.name && isleaftype(ft)
f = ft.parameters[1]
Expand Down
10 changes: 10 additions & 0 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -669,3 +669,13 @@ let m = which(T20332{Int}(), (Int,)),
end

@test sprint(show, Main) == "Main"

struct f_with_params{t} <: Function
end

(::f_with_params)(x) = 2x

let io = IOBuffer()
show(io, MIME"text/html"(), f_with_params.body.name.mt)
@test contains(String(take!(io)), "f_with_params")
end

0 comments on commit d711597

Please sign in to comment.