From a6180f66484a5351cbe5f85781eba194fb7deb6f Mon Sep 17 00:00:00 2001 From: N5N3 <2642243996@qq.com> Date: Thu, 29 Sep 2022 22:20:10 +0800 Subject: [PATCH] Make sure `UnionAll` is handled by `subtype_unionall` example from #46784 also added. --- src/subtype.c | 2 +- test/subtype.jl | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/subtype.c b/src/subtype.c index f30302ef6476b7..9509db359b159e 100644 --- a/src/subtype.c +++ b/src/subtype.c @@ -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; diff --git a/test/subtype.jl b/test/subtype.jl index 373e41afe394e1..aa4608c9800471 100644 --- a/test/subtype.jl +++ b/test/subtype.jl @@ -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}