Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Commit

Permalink
Fix call to null_safe_op() for generic case
Browse files Browse the repository at this point in the history
  • Loading branch information
nalimilan committed Nov 26, 2016
1 parent 17688ce commit 5f3e5c0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ end
end
end

eltype_nullable(x::Nullable) = eltype(x)
eltype_nullable(x) = typeof(x)
eltypes() = Tuple{}
eltypes(x) = Tuple{eltype(x)}
eltypes(x, xs...) = Tuple{eltype(x), eltypes(xs...).parameters...}
eltypes(x) = Tuple{eltype_nullable(x)}
eltypes(x, xs...) = Tuple{eltype_nullable(x), eltypes(xs...).parameters...}

hasnulls() = false
hasnulls(x) = isnull(x)
Expand All @@ -74,10 +76,10 @@ for a function call `f(xs...)`, return null if any `x` in `xs` is null; otherwis
return `f` applied to values of `xs`.
"""
@inline function broadcast_lift(f, xs...)
if null_safe_op(f, eltypes(xs).parameters...)
if null_safe_op(f, eltypes(xs...).parameters...)
return @compat Nullable(f(unsafe_get.(xs)...), !hasnulls(xs...))
else
U = Core.Inference.return_type(f, eltypes(xs))
U = Core.Inference.return_type(f, eltypes(xs...))
if hasnulls(xs...)
return Nullable{U}()
else
Expand Down

0 comments on commit 5f3e5c0

Please sign in to comment.