Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Let tmerge form a Union more often (#27843)" #39406

Merged
merged 1 commit into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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