Skip to content
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
14 changes: 2 additions & 12 deletions src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -2683,26 +2683,16 @@ static jl_value_t *intersect_invariant(jl_value_t *x, jl_value_t *y, jl_stenv_t
flip_vars(e);
return jl_bottom_type;
}
/*
TODO: This is a band-aid for issue #23685. A better solution would be to
first normalize types so that all `where` expressions in covariant position
are pulled out to the top level.
*/
if ((jl_is_typevar(x) && !jl_is_typevar(y) && lookup(e, (jl_tvar_t*)x) == NULL) ||
(jl_is_typevar(y) && !jl_is_typevar(x) && lookup(e, (jl_tvar_t*)y) == NULL))
return ii;
jl_value_t *root=NULL;
jl_savedenv_t se;
JL_GC_PUSH2(&ii, &root);
save_env(e, &root, &se);
if (!subtype_in_env(x, y, e)) {
if (!subtype_in_env_existential(x, y, e, 0, e->invdepth)) {
ii = NULL;
}
else {
flip_vars(e);
if (!subtype_in_env(y, x, e))
if (!subtype_in_env_existential(y, x, e, 0, e->invdepth))
ii = NULL;
flip_vars(e);
}
restore_env(e, root, &se);
free(se.buf);
Expand Down
11 changes: 11 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,17 @@ function test_intersection()
@test_broken typeintersect(Tuple{Type{Z},Z} where Z,
Tuple{Type{Ref{T}} where T, Ref{Float64}}) ==
Tuple{Type{Ref{Float64}},Ref{Float64}}

# issue #32607
@testintersect(Type{<:Tuple{Integer,Integer}},
Type{Tuple{Int,T}} where T,
Type{Tuple{Int,T}} where T<:Integer)
@testintersect(Type{<:Tuple{Any,Vararg{Any}}},
Type{Tuple{Vararg{Int,N}}} where N,
Type{Tuple{Int,Vararg{Int,N}}} where N)
@testintersect(Type{<:Array},
Type{AbstractArray{T}} where T,
Bottom)
end

function test_intersection_properties()
Expand Down