@@ -2241,6 +2241,16 @@ let S = Tuple{T2, V2} where {T2, N2, V2<:(Array{S2, N2} where {S2 <: T2})},
22412241 @testintersect (S, T, ! Union{})
22422242end
22432243
2244+ @test only (intersection_env (Val{Union{Val{Val{T}} where {T},Int}}, Val{Union{T,Int}} where T)[2 ]) === Val{Val{T}} where {T}
2245+
2246+ # issue 47654
2247+ Vec47654{T} = Union{AbstractVector{T}, AbstractVector{Union{T,Nothing}}}
2248+ struct Wrapper47654{T, V<: Vec47654{T} }
2249+ v:: V
2250+ end
2251+ abstract type P47654{A} end
2252+ @test Wrapper47654{P47654, Vector{Union{P47654,Nothing}}} <: Wrapper47654
2253+
22442254@testset " known subtype/intersect issue" begin
22452255 # issue 45874
22462256 # Causes a hang due to jl_critical_error calling back into malloc...
@@ -2278,7 +2288,7 @@ end
22782288 @test_broken typeintersect (Tuple{Type{Tuple{T,Val{T}}}, Val{T}} where T, Tuple{Type{Tuple{Val{T},T}}, Val{T}} where T) <: Any
22792289
22802290 # issue 24333
2281- @test_broken (Type{Union{Ref,Cvoid}} <: Type{Union{T,Cvoid}} where T)
2291+ @test (Type{Union{Ref,Cvoid}} <: Type{Union{T,Cvoid}} where T)
22822292
22832293 # issue 22123
22842294 t1 = Ref{Ref{Ref{Union{Int64, T}}} where T}
@@ -2289,4 +2299,16 @@ end
22892299 @test_broken (Tuple{T1,T1} where T1<: (Val{T2} where T2) ) <: (Tuple{Val{S},Val{S}} where S)
22902300end
22912301
2302+ # issue #47658
2303+ let T = Ref{NTuple{8 , Ref{Union{Int, P}}}} where P,
2304+ S = Ref{NTuple{8 , Ref{Union{Int, P}}}} where P
2305+ # note T and S are identical but we need 2 copies to avoid being fooled by pointer equality
2306+ @test T <: Union{Int, S}
2307+ end
2308+
2309+ # try to fool a greedy algorithm that picks X=Int, Y=String here
2310+ @test Tuple{Ref{Union{Int,String}}, Ref{Union{Int,String}}} <: Tuple{Ref{Union{X,Y}}, Ref{X}} where {X,Y}
2311+ # this slightly more complex case has been broken since 1.0 (worked in 0.6)
2312+ @test_broken Tuple{Ref{Union{Int,String,Missing}}, Ref{Union{Int,String}}} <: Tuple{Ref{Union{X,Y}}, Ref{X}} where {X,Y}
2313+
22922314@test ! (Tuple{Any, Any, Any} <: Tuple{Any, Vararg{T}} where T)
0 commit comments