diff --git a/src/array_partition.jl b/src/array_partition.jl index f1bd9717..45043081 100644 --- a/src/array_partition.jl +++ b/src/array_partition.jl @@ -7,7 +7,7 @@ end ArrayPartition(x...) = ArrayPartition((x...,)) function ArrayPartition(x::S, ::Type{Val{copy_x}}=Val{false}) where {S<:Tuple,copy_x} - T = promote_type(eltype.(x)...) + T = promote_type(recursive_bottom_eltype.(x)...) if copy_x return ArrayPartition{T,S}(copy.(x)) else diff --git a/test/partitions_and_static_arrays.jl b/test/partitions_and_static_arrays.jl new file mode 100644 index 00000000..f0b4f6a0 --- /dev/null +++ b/test/partitions_and_static_arrays.jl @@ -0,0 +1,10 @@ +using Test, RecursiveArrayTools, StaticArrays + +p = ArrayPartition((zeros(Float32, 2), zeros(SMatrix{2,2, Int64},2), zeros(SVector{3, Float64}, 2))) +@test eltype(p)==Float64 +@test recursive_bottom_eltype(p)==Float64 +@test recursive_unitless_eltype(p)==Float64 +@test recursive_unitless_bottom_eltype(p)==Float64 + +p2 = similar(p) +@test typeof(p2)==typeof(p)