Skip to content

Commit

Permalink
Set intersection = 1 during intersect_sub_datatype (#46882)
Browse files Browse the repository at this point in the history
(cherry picked from commit e6d9979)
  • Loading branch information
N5N3 authored and KristofferC committed Oct 28, 2022
1 parent 97ccb97 commit 85155e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -2840,7 +2840,7 @@ static jl_value_t *intersect_sub_datatype(jl_datatype_t *xd, jl_datatype_t *yd,
JL_GC_PUSHARGS(env, envsz);
jl_stenv_t tempe;
init_stenv(&tempe, env, envsz);
tempe.ignore_free = 1;
tempe.intersection = tempe.ignore_free = 1;
if (subtype_in_env(isuper, super_pattern, &tempe)) {
jl_value_t *wr = wrapper;
int i;
Expand Down
7 changes: 7 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2031,3 +2031,10 @@ S46735{B<:Val, M<:AbstractMatrix} = Tuple{<:Union{B, <:Val{<:B}},M,<:(Union{Abst
A46735{B<:Val, M<:AbstractMatrix} = Tuple{<:Union{B, <:Val{<:B}},M,Union{AbstractMatrix{B}, AbstractMatrix{<:Vector{<:B}}}}
@testintersect(A46735{B} where {B}, A46735, !Union{})
@testintersect(A46735{B, M} where {B, M}, A46735, !Union{})

#issue #46871
struct A46871{T, N, M} <: AbstractArray{T, N} end
struct B46871{T, N} <: Ref{A46871{T, N, N}} end
for T in (B46871{Int, N} where {N}, B46871{Int}) # intentional duplication
@testintersect(T, Ref{<:AbstractArray{<:Real, 3}}, B46871{Int, 3})
end

0 comments on commit 85155e1

Please sign in to comment.