Skip to content

Commit

Permalink
fix a bug in typeintersect with Type
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jan 13, 2017
1 parent 945c054 commit 506674e
Show file tree
Hide file tree
Showing 2 changed files with 6 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 @@ -1785,7 +1785,7 @@ jl_value_t *jl_type_intersection_matching(jl_value_t *a, jl_value_t *b, jl_svec_
// we assume that if the intersection is a leaf type, we have
// full information in `env`. however the intersection algorithm
// does not yet provide that in all cases so use subtype.
if (szb > 0 && jl_is_leaf_type(*ans)) {
if (szb > 0 && jl_is_leaf_type(*ans) && !jl_types_equal(b, (jl_value_t*)jl_type_type)) {
if (jl_subtype_env(*ans, b, env, szb)) {
for(i=0; i < sz; i++) {
if (jl_is_typevar(env[i])) {
Expand Down
5 changes: 5 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,11 @@ function test_intersection()

@testintersect(DataType, Type, DataType)
@testintersect(DataType, Type{T} where T<:Integer, Type{T} where T<:Integer)
@testintersect(Union{DataType,Int}, Type, DataType)
@testintersect(Union{DataType,Int}, Type{T} where T, DataType)
# test typeintersect wrapper as well as _type_intersect
@test typeintersect(Union{DataType,Int}, Type) === DataType
@test typeintersect(Union{DataType,Int}, Type{T} where T) === DataType

@testintersect((Type{Tuple{Vararg{T}}} where T), Type{Tuple}, Bottom)
@testintersect(Tuple{Type{S}, Tuple{Any, Vararg{Any}}} where S<:Tuple{Any, Vararg{Any}},
Expand Down

0 comments on commit 506674e

Please sign in to comment.