@@ -149,10 +149,16 @@ similar(::Type{A},::Type{T},s::Size{S}) where {A<:Array,T,S} = sizedarray_simila
149149# Support tuples of mixtures of `SOneTo`s alongside the normal `Integer` and `OneTo` options
150150# by simply converting them to either a tuple of Ints or a Size, re-dispatching to either one
151151# of the above methods (in the case of Size) or a base fallback (in the case of Ints).
152+ const HeterogeneousBaseShape = Union{Integer, Base. OneTo}
152153const HeterogeneousShape = Union{Integer, Base. OneTo, SOneTo}
153-
154- similar (A:: AbstractArray , :: Type{T} , shape:: Tuple{HeterogeneousShape, Vararg{HeterogeneousShape}} ) where {T} = similar (A, T, homogenize_shape (shape))
155- similar (:: Type{A} , shape:: Tuple{HeterogeneousShape, Vararg{HeterogeneousShape}} ) where {A<: AbstractArray } = similar (A, homogenize_shape (shape))
154+ const HeterogeneousShapeTuple = Union{
155+ Tuple{SOneTo, Vararg{HeterogeneousShape}},
156+ Tuple{HeterogeneousBaseShape, SOneTo, Vararg{HeterogeneousShape}},
157+ Tuple{HeterogeneousBaseShape, HeterogeneousBaseShape, SOneTo, Vararg{HeterogeneousShape}}
158+ }
159+
160+ similar (A:: AbstractArray , :: Type{T} , shape:: HeterogeneousShapeTuple ) where {T} = similar (A, T, homogenize_shape (shape))
161+ similar (:: Type{A} , shape:: HeterogeneousShapeTuple ) where {A<: AbstractArray } = similar (A, homogenize_shape (shape))
156162# Use an Array for StaticArrays if we don't have a statically-known size
157163similar (:: Type{A} , shape:: Tuple{Int, Vararg{Int}} ) where {A<: StaticArray } = Array {eltype(A)} (undef, shape)
158164
0 commit comments