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
9 changes: 7 additions & 2 deletions src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -2464,8 +2464,10 @@ static jl_value_t *intersect_aside(jl_value_t *x, jl_value_t *y, jl_stenv_t *e,
return y;
if (y == (jl_value_t*)jl_any_type && !jl_is_typevar(x))
return x;
// band-aid for #46736
if (obviously_egal(x, y))
// band-aid for #46736 #56040
if (obviously_in_union(x, y))
return y;
if (obviously_in_union(y, x))
return x;

jl_varbinding_t *vars = NULL;
Expand Down Expand Up @@ -2495,6 +2497,9 @@ static jl_value_t *intersect_aside(jl_value_t *x, jl_value_t *y, jl_stenv_t *e,

static jl_value_t *intersect_union(jl_value_t *x, jl_uniontype_t *u, jl_stenv_t *e, int8_t R, int param)
{
// band-aid for #56040
if (!jl_is_uniontype(x) && obviously_in_union((jl_value_t *)u, x))
return x;
int no_free = !jl_has_free_typevars(x) && !jl_has_free_typevars((jl_value_t*)u);
if (param == 2 || no_free) {
jl_value_t *a=NULL, *b=NULL;
Expand Down
9 changes: 9 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2721,3 +2721,12 @@ let T1 = NTuple{12, Union{Val{1}, Val{2}, Val{3}, Val{4}, Val{5}, Val{6}}}
@test !(T1 <: T2)
@test Tuple{Union{Val{1},Val{2}}} <: Tuple{S} where {T, S<:Val{T}}
end

#issue 56040
let S = Dict{V,V} where {V},
T = Dict{Ref{Union{Set{A2}, Set{A3}, A3}}, Ref{Union{Set{A3}, Set{A2}, Set{A1}, Set{A4}, A4}}} where {A1, A2<:Set{A1}, A3<:Union{Set{A1}, Set{A2}}, A4<:Union{Set{A2}, Set{A1}, Set{A3}}},
A = Dict{Ref{Set{Union{}}}, Ref{Set{Union{}}}}
@testintersect(S, T, !Union{})
@test A <: typeintersect(S, T)
@test A <: typeintersect(T, S)
end
Loading