Skip to content

Commit

Permalink
fix #36869, incorrect intersection with Union in supertype (#36996)
Browse files Browse the repository at this point in the history
(cherry picked from commit 102c9ac)
  • Loading branch information
JeffBezanson authored and KristofferC committed Aug 13, 2020
1 parent dc767cf commit 7fa0eba
Show file tree
Hide file tree
Showing 2 changed files with 8 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 @@ -2750,7 +2750,7 @@ static jl_value_t *intersect_sub_datatype(jl_datatype_t *xd, jl_datatype_t *yd,
jl_value_t *isuper = R ? intersect((jl_value_t*)yd, (jl_value_t*)xd->super, e, param) :
intersect((jl_value_t*)xd->super, (jl_value_t*)yd, e, param);
if (isuper == jl_bottom_type) return jl_bottom_type;
if (jl_nparams(xd) == 0 || jl_nparams(xd->super) == 0)
if (jl_nparams(xd) == 0 || jl_nparams(xd->super) == 0 || !jl_has_free_typevars(xd))
return (jl_value_t*)xd;
jl_value_t *super_pattern=NULL;
JL_GC_PUSH2(&isuper, &super_pattern);
Expand Down
7 changes: 7 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1757,3 +1757,10 @@ s26065 = Ref{Tuple{T,Ref{Union{Ref{Tuple{Ref{Union{Ref{Ref{Tuple{Ref{Tuple{Union
# issue 36100
@test NamedTuple{(:a, :b), Tuple{Missing, Union{}}} == NamedTuple{(:a, :b), Tuple{Missing, Union{}}}
@test Val{Tuple{Missing, Union{}}} === Val{Tuple{Missing, Union{}}}

# issue #36869
struct F36869{T, V} <: AbstractArray{Union{T, V}, 1}
end
@testintersect(Tuple{Type{T}, AbstractVector{T}} where T,
Tuple{Union, F36869{Int64, Missing}},
Tuple{Union, F36869{Int64, Missing}})

0 comments on commit 7fa0eba

Please sign in to comment.