Skip to content

Commit

Permalink
Fix regression on StaticArray
Browse files Browse the repository at this point in the history
  • Loading branch information
N5N3 committed Feb 10, 2022
1 parent c7a4dc8 commit 793d035
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/staticarrays_support.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import StaticArrays: StaticArray, FieldArray, tuple_prod
import StaticArrays: StaticArray, FieldArray, tuple_prod, StaticArrayStyle

"""
StructArrays.staticschema(::Type{<:StaticArray{S, T}}) where {S, T}
Expand Down Expand Up @@ -26,4 +26,9 @@ StructArrays.component(s::StaticArray, i) = getindex(s, i)
invoke(StructArrays.staticschema, Tuple{Type{<:Any}}, T)
end
StructArrays.component(s::FieldArray, i) = invoke(StructArrays.component, Tuple{Any, Any}, s, i)
StructArrays.createinstance(T::Type{<:FieldArray}, args...) = invoke(createinstance, Tuple{Type{<:Any}, Vararg}, T, args...)
StructArrays.createinstance(T::Type{<:FieldArray}, args...) = invoke(createinstance, Tuple{Type{<:Any}, Vararg}, T, args...)

function Base.copy(bc::Broadcasted{<:StructArrayStyle{StaticArrayStyle{N}}}) where {N}
B = convert(Broadcasted{Broadcast.DefaultArrayStyle{N}}, bc)
copy(B)
end
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,10 @@ Base.BroadcastStyle(::Broadcast.ArrayStyle{MyArray1}, ::Broadcast.ArrayStyle{MyA
a = StructArray([1;2+im])
b = StructArray([1 2+im])
@test @inferred(a .+ b .+ a .* a' .+ (1,2) .+ (1:2) .- b') isa StructArray

a = @SArray randn(3,3);
b = StructArray{ComplexF64}((a,a))
@test a[:,1] .+ b isa SizedMatrix
end

@testset "staticarrays" begin
Expand Down

0 comments on commit 793d035

Please sign in to comment.