Skip to content

Commit

Permalink
Remove special treatment of Tuples from tmerge
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholters committed Nov 9, 2017
1 parent cfd039b commit 7a26e18
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
11 changes: 0 additions & 11 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2798,17 +2798,6 @@ function tmerge(@nospecialize(typea), @nospecialize(typeb))
if !(isa(typea,Type) || isa(typea,TypeVar)) || !(isa(typeb,Type) || isa(typeb,TypeVar))
return Any
end
if (typea <: Tuple) && (typeb <: Tuple)
if isa(typea, DataType) && isa(typeb, DataType) && length(typea.parameters) == length(typeb.parameters) && !isvatuple(typea) && !isvatuple(typeb)
return typejoin(typea, typeb)
end
if isa(typea, Union) || isa(typeb, Union) || (isa(typea,DataType) && length(typea.parameters)>3) ||
(isa(typeb,DataType) && length(typeb.parameters)>3)
# widen tuples faster (see #6704), but not too much, to make sure we can infer
# e.g. (t::Union{Tuple{Bool},Tuple{Bool,Int}})[1]
return Tuple
end
end
u = Union{typea, typeb}
if unionlen(u) > MAX_TYPEUNION_LEN
u = typejoin(typea, typeb)
Expand Down
2 changes: 2 additions & 0 deletions test/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1294,3 +1294,5 @@ end

f_23077(x) = (Int8(0), Int16(0), Int32(0), Int64(0))[x]
@test Base.return_types(f_23077, Tuple{Int})[1] <: Signed
g_23077(x,y,z) = x ? y ? z ? (1,) : (1,1.0) : (1,1) : (1,1.0,1)
@test Base.return_types(g_23077, Tuple{Bool,Bool,Bool})[1] <: Tuple{Int,Vararg{Real}}

0 comments on commit 7a26e18

Please sign in to comment.