Skip to content

Commit 1553bc2

Browse files
committed
Add eachindex method for OptionallyStaticRanges and fix an error when using StaticArrays <v1.
1 parent 3ca6cc7 commit 1553bc2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/ArrayInterface.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,11 @@ function __init__()
760760
end
761761
t
762762
end
763-
parent_type(::Type{<:StaticArrays.SizedArray{S, T, M, N, A}}) where {S,T,M,N,A} = A
763+
if StaticArrays.SizedArray{Tuple{8, 8}, Float64, 2, 2} isa UnionAll
764+
parent_type(::Type{<:StaticArrays.SizedArray{S, T, M, N, A}}) where {S,T,M,N,A} = A
765+
else
766+
parent_type(::Type{<:StaticArrays.SizedArray{S, T, M, N}}) where {S,T,M,N} = Array{T,N}
767+
end
764768
@require Adapt="79e6a3ab-5dfb-504d-930d-738a2a938a0e" begin
765769
function Adapt.adapt_storage(::Type{<:StaticArrays.SArray{S}},xs::Array) where S
766770
StaticArrays.SArray{S}(xs)

src/ranges.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ end
372372

373373
const OptionallyStaticRange = Union{<:OptionallyStaticUnitRange,<:OptionallyStaticStepRange}
374374

375+
Base.eachindex(r::OptionallyStaticRange) = r
376+
375377
Base.to_shape(x::OptionallyStaticRange) = length(x)
376378
Base.to_shape(x::Slice{T}) where {T<:OptionallyStaticRange} = length(x)
377379

0 commit comments

Comments
 (0)