Skip to content

Commit 32537f2

Browse files
committed
Remove special treatment of Tuples from tmerge
1 parent 4b06e32 commit 32537f2

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
@@ -2798,17 +2798,6 @@ function tmerge(@nospecialize(typea), @nospecialize(typeb))
27982798
if !(isa(typea,Type) || isa(typea,TypeVar)) || !(isa(typeb,Type) || isa(typeb,TypeVar))
27992799
return Any
28002800
end
2801-
if (typea <: Tuple) && (typeb <: Tuple)
2802-
if isa(typea, DataType) && isa(typeb, DataType) && length(typea.parameters) == length(typeb.parameters) && !isvatuple(typea) && !isvatuple(typeb)
2803-
return typejoin(typea, typeb)
2804-
end
2805-
if isa(typea, Union) || isa(typeb, Union) || (isa(typea,DataType) && length(typea.parameters)>3) ||
2806-
(isa(typeb,DataType) && length(typeb.parameters)>3)
2807-
# widen tuples faster (see #6704), but not too much, to make sure we can infer
2808-
# e.g. (t::Union{Tuple{Bool},Tuple{Bool,Int}})[1]
2809-
return Tuple
2810-
end
2811-
end
28122801
u = Union{typea, typeb}
28132802
if unionlen(u) > MAX_TYPEUNION_LEN
28142803
u = typejoin(typea, typeb)

test/inference.jl

+2
Original file line numberDiff line numberDiff line change
@@ -1294,3 +1294,5 @@ end
12941294

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

0 commit comments

Comments
 (0)