Skip to content

Commit

Permalink
Allow union_poptype to handle partially-overlapping unions
Browse files Browse the repository at this point in the history
Previously, `union_poptype` would fail if the arguments only partially
overlapped: i.e. `union_poptype(Union{A, B}, Union{A, C})`. First taking the
union of all the types allows `union_poptype` even in this edge-case.
  • Loading branch information
galenlynch committed Jan 17, 2019
1 parent 8d80f7e commit 60391fd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions base/skipoftype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ mapreduce_impl(f, op, A::SkipOfType, ifirst::Integer, ilast::Integer) =
end
end

union_poptype(::Type{T}, ::Type{Union{T,S}}) where {T, S} = S
union_poptype(::Type{T}, ::Type{S}) where {T, S} = S
union_poptype(::Type{T}, ::Type{T}) where {T} = Union{}
_union_poptype(::Type{T}, ::Type{Union{T,S}}) where {T, S} = S
_union_poptype(::Type{T}, ::Type{T}) where {T} = Union{}

# Necessary for cases like _union_poptype(Union{A,B}, Union{A,C})
union_poptype(::Type{T}, ::Type{S}) where {T, S} = _union_poptype(T, Union{T,S})

0 comments on commit 60391fd

Please sign in to comment.