Skip to content

Commit

Permalink
Make sure UnionAll is handled by subtype_unionall
Browse files Browse the repository at this point in the history
example from JuliaLang#46784 also added.
  • Loading branch information
N5N3 committed Sep 29, 2022
1 parent 9fd4087 commit a6180f6
Show file tree
Hide file tree
Showing 2 changed files with 7 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 @@ -562,7 +562,7 @@ static int subtype_ccheck(jl_value_t *x, jl_value_t *y, jl_stenv_t *e)

static int subtype_left_var(jl_value_t *x, jl_value_t *y, jl_stenv_t *e, int param)
{
if (x == y)
if (x == y && !(jl_is_unionall(y)))
return 1;
if (x == jl_bottom_type && jl_is_type(y))
return 1;
Expand Down
6 changes: 6 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2189,3 +2189,9 @@ 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

#issue #46970
@test only(intersection_env(Union{S, Matrix{Int}} where S<:Matrix, Matrix)[2]) isa TypeVar
T46784{B<:Val, M<:AbstractMatrix} = Tuple{<:Union{B, <:Val{<:B}}, M, Union{AbstractMatrix{B}, AbstractMatrix{<:Vector{<:B}}}}
@testintersect(T46784{T,S} where {T,S}, T46784, !Union{})
@test_broken T46784 <: T46784{T,S} where {T,S}

0 comments on commit a6180f6

Please sign in to comment.