Skip to content

Commit 9ba2769

Browse files
committed
1.6 fix + cov fix
1 parent dfae5ad commit 9ba2769

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/staticarrays_support.jl

+10-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,16 @@ replace_structarray_args(::Tuple{}) = ()
6161
ET = eltype(sa)
6262
isnonemptystructtype(ET) || return sa
6363
elements = Tuple(sa)
64-
arrs = ntuple(Val(fieldcount(ET))) do i
65-
similar_type(sa, fieldtype(ET, i))(_getfields(elements, i))
64+
@static if VERSION >= v"1.7"
65+
arrs = ntuple(Val(fieldcount(ET))) do i
66+
similar_type(sa, fieldtype(ET, i))(_getfields(elements, i))
67+
end
68+
else
69+
_fieldtype(::Type{T}) where {T} = i -> fieldtype(T, i)
70+
__fieldtype = _fieldtype(ET)
71+
arrs = ntuple(Val(fieldcount(ET))) do i
72+
similar_type(sa, __fieldtype(i))(_getfields(elements, i))
73+
end
6674
end
6775
return StructArray{ET}(arrs)
6876
end

test/runtests.jl

+4
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,10 @@ Base.BroadcastStyle(::Broadcast.ArrayStyle{MyArray2}, S::Broadcast.DefaultArrayS
11981198
s = StructArray{ComplexF64}((a , b))
11991199
@test (@inferred bclog(s)) isa typeof(s)
12001200
test_allocated(bclog, s)
1201+
@test abs.(s) .+ ((1,) .+ (1,2,3,4,5,6,7,8,9,10)) isa SMatrix
1202+
bc = Base.broadcasted(+, s, s);
1203+
bc = Base.broadcasted(+, bc, bc, s);
1204+
@test @inferred(Broadcast.axes(bc)) === axes(s)
12011205
end
12021206

12031207
@testset "StructJLArray" begin

0 commit comments

Comments
 (0)