diff --git a/src/jltypes.c b/src/jltypes.c index 3122593409199..b038be3ed58b3 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -659,7 +659,7 @@ static jl_value_t *intersect_typevar(jl_tvar_t *a, jl_value_t *b, if (b == jl_bottom_type) return b; } - if (var == invariant && !jl_has_typevars_(b,0)) { + if (var == invariant && !jl_has_typevars_(b,0) && !jl_is_typevar(b)) { int i; for(i=0; i < eqc->n; i+=2) { if (eqc->data[i] == (jl_value_t*)a) { diff --git a/test/core.jl b/test/core.jl index c93fa6b4fcfa0..a5f785e3f42b6 100644 --- a/test/core.jl +++ b/test/core.jl @@ -56,6 +56,11 @@ let T = TypeVar(:T,true) # issue #5359 @test typeintersect((Type{Array{T,1}},Array{T,1}), (Type{AbstractVector},Vector{Int})) === None + # issue #5559 + @test typeintersect((Type{Vector{Complex128}}, AbstractVector), + (Type{Array{T,N}}, Array{S,N})) == (Type{Vector{Complex128}},Vector) + @test typeintersect((Type{Vector{Complex128}}, AbstractArray), + (Type{Array{T,N}}, Array{S,N})) == (Type{Vector{Complex128}},Vector) end let N = TypeVar(:N,true) @test isequal(typeintersect((NTuple{N,Integer},NTuple{N,Integer}),