Skip to content

Commit

Permalink
fix #22798, displaying generated function signatures without `.source…
Browse files Browse the repository at this point in the history
…` defined
  • Loading branch information
JeffBezanson committed Jul 13, 2017
1 parent 9c1d1b8 commit 259c3f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions base/methodshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ function arg_decl_parts(m::Method)
end
file = m.file
line = m.line
if isdefined(m, :source)
if isdefined(m, :source) || isdefined(m, :generator)
argnames = Vector{Any}(m.nargs)
ccall(:jl_fill_argnames, Void, (Any, Any), m.source, argnames)
ccall(:jl_fill_argnames, Void, (Any, Any), isdefined(m, :source) ? m.source : m.generator.inferred, argnames)
show_env = ImmutableDict{Symbol, Any}()
for t in tv
show_env = ImmutableDict(show_env, :unionall_env => t)
Expand All @@ -71,7 +71,7 @@ function kwarg_decl(m::Method, kwtype::DataType)
kwli = ccall(:jl_methtable_lookup, Any, (Any, Any, UInt), kwtype.name.mt, sig, typemax(UInt))
if kwli !== nothing
kwli = kwli::Method
src = uncompressed_ast(kwli, kwli.source)
src = uncompressed_ast(kwli)
kws = filter(x -> !('#' in string(x)), src.slotnames[(kwli.nargs + 1):end])
# ensure the kwarg... is always printed last. The order of the arguments are not
# necessarily the same as defined in the function
Expand Down
7 changes: 7 additions & 0 deletions test/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -575,3 +575,10 @@ end
@test !contains(str, "The applicable method may be too new")
end
end

# issue #22798
@generated f22798(x::Integer, y) = :x
let buf = IOBuffer()
show(buf, methods(f22798))
@test contains(String(take!(buf)), "f22798(x::Integer, y)")
end

0 comments on commit 259c3f1

Please sign in to comment.