Skip to content

Commit

Permalink
add inference support for splatting constant containers
Browse files Browse the repository at this point in the history
fixes #10880
  • Loading branch information
JeffBezanson committed Apr 22, 2016
1 parent 158f46c commit 66c299f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,10 @@ function precise_container_types(args, types, vtypes::VarTable, sv)
result = cell(n)
for i = 1:n
ai = args[i]; ti = types[i]; tti = widenconst(ti)
if isa(ai,Expr) && ai.head === :call && (abstract_evals_to_constant(ai.args[1], svec, vtypes, sv) ||
abstract_evals_to_constant(ai.args[1], tuple, vtypes, sv))
if isa(ti, Const) && (isa(ti.val, SimpleVector) || isa(ti.val, Tuple))
result[i] = Any[ abstract_eval_constant(x) for x in ti.val ]
elseif isa(ai,Expr) && ai.head === :call && (abstract_evals_to_constant(ai.args[1], svec, vtypes, sv) ||
abstract_evals_to_constant(ai.args[1], tuple, vtypes, sv))
aa = ai.args
result[i] = Any[ (isa(aa[j],Expr) ? aa[j].typ : abstract_eval(aa[j],vtypes,sv)) for j=2:length(aa) ]
if _any(isvarargtype, result[i])
Expand Down
7 changes: 7 additions & 0 deletions test/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,10 @@ end
let g() = Int <: Real ? 1 : ""
@test Base.return_types(g, Tuple{}) == [Int]
end

# issue #10880
function cat10880(a, b)
Tuple{a.parameters..., b.parameters...}
end
@test Base.return_types(cat10880, Tuple{Type{Tuple{Int8,Int16}},Type{Tuple{Int32}}})[1] ==
Type{Tuple{Int8,Int16,Int32}}

0 comments on commit 66c299f

Please sign in to comment.