Skip to content

Commit dc920bc

Browse files
committed
Remove special treatment of Tuples from tmerge
1 parent 940f59e commit dc920bc

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

base/inference.jl

-11
Original file line numberDiff line numberDiff line change
@@ -2607,17 +2607,6 @@ function tmerge(@nospecialize(typea), @nospecialize(typeb))
26072607
if !(isa(typea,Type) || isa(typea,TypeVar)) || !(isa(typeb,Type) || isa(typeb,TypeVar))
26082608
return Any
26092609
end
2610-
if (typea <: Tuple) && (typeb <: Tuple)
2611-
if isa(typea, DataType) && isa(typeb, DataType) && length(typea.parameters) == length(typeb.parameters) && !isvatuple(typea) && !isvatuple(typeb)
2612-
return typejoin(typea, typeb)
2613-
end
2614-
if isa(typea, Union) || isa(typeb, Union) || (isa(typea,DataType) && length(typea.parameters)>3) ||
2615-
(isa(typeb,DataType) && length(typeb.parameters)>3)
2616-
# widen tuples faster (see #6704), but not too much, to make sure we can infer
2617-
# e.g. (t::Union{Tuple{Bool},Tuple{Bool,Int}})[1]
2618-
return Tuple
2619-
end
2620-
end
26212610
u = Union{typea, typeb}
26222611
if unionlen(u) > MAX_TYPEUNION_LEN
26232612
u = typejoin(typea, typeb)

test/inference.jl

+2
Original file line numberDiff line numberDiff line change
@@ -1105,3 +1105,5 @@ end
11051105

11061106
f_ADD_PR_NUMBER(x) = (Int8(0), Int16(0), Int32(0), Int64(0))[x]
11071107
@test Base.return_types(f_ADD_PR_NUMBER, Tuple{Int})[1] <: Signed
1108+
g_ADD_PR_NUMBER(x,y,z) = x ? y ? z ? (1,) : (1,1.0) : (1,1) : (1,1.0,1)
1109+
@test Base.return_types(g_ADD_PR_NUMBER, Tuple{Bool,Bool,Bool})[1] <: Tuple{Int64,Vararg{Real}}

0 commit comments

Comments
 (0)