Skip to content

Commit

Permalink
Fix JuliaLang#16326: use typeof in code_* for all :call expressions
Browse files Browse the repository at this point in the history
Update docs/utils.jl to pass test (h/t MichaelHatherly).
  • Loading branch information
ihnorton committed Jul 2, 2016
1 parent e121955 commit ec8e52f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
8 changes: 2 additions & 6 deletions base/docs/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,8 @@ repl(str::AbstractString) = :(apropos($str))
repl(other) = :(@doc $(esc(other)))

function _repl(x)
docs = :(@doc $(esc(x)))
if isexpr(x, :call)
# Handles function call syntax where each argument is an atom (symbol, number, etc.)
t = Base.gen_call_with_extracted_types(doc, x)
(isexpr(t, :call, 3) && t.args[1] === doc) && (docs = t)
end
docs = (isexpr(x, :call) && !any(isexpr(x, :(::)) for x in x.args)) ?
Base.gen_call_with_extracted_types(doc, x) : :(@doc $(esc(x)))
if isfield(x)
quote
if isa($(esc(x.args[1])), DataType)
Expand Down
3 changes: 2 additions & 1 deletion base/interactiveutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ typesof(args...) = Tuple{map(a->(isa(a,Type) ? Type{a} : typeof(a)), args)...}
gen_call_with_extracted_types(fcn, ex0::Symbol) = Expr(:call, fcn, Meta.quot(ex0))
function gen_call_with_extracted_types(fcn, ex0)
if isa(ex0, Expr) &&
any(a->(Meta.isexpr(a, :kw) || Meta.isexpr(a, :parameters)), ex0.args)
(any(a->(Meta.isexpr(a, :kw) || Meta.isexpr(a, :parameters)), ex0.args) ||
ex0.head == :call)
# keyword args not used in dispatch, so just remove them
args = filter(a->!(Meta.isexpr(a, :kw) || Meta.isexpr(a, :parameters)), ex0.args)
return Expr(:call, fcn, esc(args[1]),
Expand Down

0 comments on commit ec8e52f

Please sign in to comment.