@@ -88,7 +88,7 @@ Returns the axis associated with each dimension of `A` or dimension `dim`.
8888exception of a handful of types replace `Base.OneTo{Int}` with `ArrayInterface.SOneTo`. For
8989example, the axis along the first dimension of `Transpose{T,<:AbstractVector{T}}` and
9090`Adjoint{T,<:AbstractVector{T}}` can be represented by `SOneTo(1)`. Similarly,
91- `Base.ReinterpretArray`'s first axis may be statically sized.
91+ `Base.ReinterpretArray`'s first axis may be statically sized.
9292"""
9393@inline axes (A) = Base. axes (A)
9494axes (A:: ReshapedArray ) = Base. axes (A)
112112 return getfield (axes (A), Int (dim))
113113 end
114114end
115- axes (A:: SubArray , dim) = Base. axes (getindex (A. indices, to_parent_dims (A, to_dims (A, dim))), 1 )
115+
116+ @inline function axes (A:: SubArray , dim:: Integer )
117+ if dim > ndims (A)
118+ return OneTo (1 )
119+ else
120+ return axes (getindex (A. indices, to_parent_dims (A, to_dims (A, dim))), 1 )
121+ end
122+ end
123+ @inline function axes (A:: SubArray , :: StaticInt{dim} ) where {dim}
124+ if dim > ndims (A)
125+ return SOneTo {1} ()
126+ else
127+ return axes (getindex (A. indices, to_parent_dims (A, to_dims (A, dim))), 1 )
128+ end
129+ end
130+
116131if isdefined (Base, :ReshapedReinterpretArray )
117132 function axes_types (:: Type{A} ) where {T,N,S,A<: Base.ReshapedReinterpretArray{T,N,S} }
118133 if sizeof (S) > sizeof (T)
0 commit comments