Skip to content

Commit

Permalink
Revert "Let tmerge form a Union more often (#27843)"
Browse files Browse the repository at this point in the history
This reverts commit 6c1824d.
  • Loading branch information
JeffBezanson committed Jan 26, 2021
1 parent cd35195 commit dc4a37b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
7 changes: 3 additions & 4 deletions base/compiler/typelimits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,9 @@ function tmerge(@nospecialize(typea), @nospecialize(typeb))
return Any
end
typea == typeb && return typea
# it's always ok to form a Union of two Union-free types
u = Union{typea, typeb}
if unioncomplexity(u) <= 1
return u
# it's always ok to form a Union of two concrete types
if (isconcretetype(typea) || isType(typea)) && (isconcretetype(typeb) || isType(typeb))
return Union{typea, typeb}
end
# collect the list of types from past tmerge calls returning Union
# and then reduce over that list
Expand Down
10 changes: 0 additions & 10 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2041,16 +2041,6 @@ let rt = Base.return_types(splat27434, (NamedTuple{(:x,), Tuple{T}} where T,))
@test !Base.has_free_typevars(rt[1])
end

# PR #27843
bar27843(x, y::Bool) = fill(x, 0)
bar27843(x, y) = fill(x, ntuple(_ -> 0, y))::Array{typeof(x)}
foo27843(x, y) = bar27843(x, y)
@test Core.Compiler.return_type(foo27843, Tuple{Union{Float64,Int}, Any}) == Union{Array{Float64}, Array{Int}}
let atypes1 = Tuple{Union{IndexCartesian, IndexLinear}, Any, Union{Tuple{}, Tuple{Any,Vararg{Any,N}} where N}, Tuple},
atypes2 = Tuple{Union{IndexCartesian, IndexLinear}, Any, Tuple, Tuple}
@test Core.Compiler.return_type(SubArray, atypes1) <: Core.Compiler.return_type(SubArray, atypes2)
end

# issue #27078
f27078(T::Type{S}) where {S} = isa(T, UnionAll) ? f27078(T.body) : T
T27078 = Vector{Vector{T}} where T
Expand Down

0 comments on commit dc4a37b

Please sign in to comment.