Skip to content

Commit 8869461

Browse files
committed
Fix ambiguity
1 parent 1f0f5db commit 8869461

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/diffeqfastbc.jl

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,23 @@ preprocess_args(f::typeof(diffeqbc), dest, args::Tuple{}) = ()
4242

4343
# Performance optimization for the common identity scalar case: dest .= val
4444
@inline copyto!(dest::DiffEqBC, bc::Broadcasted{<:AbstractArrayStyle{0}}) = copyto!(dest.x, bc)
45-
@inline function copyto!(dest::DiffEqBC, bc::Broadcasted)
46-
axes(dest) == axes(bc) || throwdm(axes(dest), axes(bc))
47-
dest′ = dest.x
48-
# Performance optimization: broadcast!(identity, dest, A) is equivalent to copyto!(dest, A) if indices match
49-
if bc.f === identity && bc.args isa Tuple{AbstractArray} # only a single input argument to broadcast!
50-
A = bc.args[1]
51-
if axes(dest) == axes(A)
52-
return copyto!(dest′, A)
53-
end
54-
end
55-
bcs′ = preprocess(diffeqbc, dest, bc)
56-
@simd ivdep for I in eachindex(bcs′)
57-
@inbounds dest′[I] = bcs′[I]
58-
end
59-
return dest′ # return the original array without the wrapper
45+
for B in (Broadcasted, Broadcasted{<:StaticArrays.StaticArrayStyle}) # fix ambiguity
46+
@eval @inline function copyto!(dest::DiffEqBC, bc::$B)
47+
axes(dest) == axes(bc) || throwdm(axes(dest), axes(bc))
48+
dest′ = dest.x
49+
# Performance optimization: broadcast!(identity, dest, A) is equivalent to copyto!(dest, A) if indices match
50+
if bc.f === identity && bc.args isa Tuple{AbstractArray} # only a single input argument to broadcast!
51+
A = bc.args[1]
52+
if axes(dest) == axes(A)
53+
return copyto!(dest′, A)
54+
end
55+
end
56+
bcs′ = preprocess(diffeqbc, dest, bc)
57+
@simd ivdep for I in eachindex(bcs′)
58+
@inbounds dest′[I] = bcs′[I]
59+
end
60+
return dest′ # return the original array without the wrapper
61+
end
6062
end
6163

6264
# Forcing `broadcasted` to inline is not necessary, since `Vern9` plays well

0 commit comments

Comments
 (0)