@@ -365,7 +365,7 @@ function checkbounds_indices(::Type{Bool}, IA::Tuple, I::Tuple{Any})
365365 @_inline_meta
366366 checkbounds_linear_indices (Bool, IA, I[1 ])
367367end
368- function checkbounds_linear_indices (:: Type{Bool} , IA:: Tuple , i)
368+ function checkbounds_linear_indices (:: Type{Bool} , IA:: Tuple{Vararg{OneTo}} , i)
369369 @_inline_meta
370370 if checkindex (Bool, IA[1 ], i)
371371 return true
@@ -375,6 +375,10 @@ function checkbounds_linear_indices(::Type{Bool}, IA::Tuple, i)
375375 end
376376 return false
377377end
378+ function checkbounds_linear_indices (:: Type{Bool} , IA:: Tuple{AbstractUnitRange,Vararg{AbstractUnitRange}} , i)
379+ @_inline_meta
380+ checkindex (Bool, IA[1 ], i)
381+ end
378382function checkbounds_linear_indices (:: Type{Bool} , IA:: Tuple , i:: Union{Slice,Colon} )
379383 partial_linear_indexing_warning_lookup (length (IA))
380384 true
@@ -853,10 +857,24 @@ _to_subscript_indices{T}(A::AbstractArray{T,0}, i::Int) = () # TODO: REMOVE FOR
853857_to_subscript_indices {T} (A:: AbstractArray{T,0} , I:: Int... ) = () # TODO : DEPRECATE FOR #14770
854858function _to_subscript_indices {T,N} (A:: AbstractArray{T,N} , I:: Int... ) # TODO : DEPRECATE FOR #14770
855859 @_inline_meta
856- J, _ = IteratorsMD. split (I, Val{N}) # (maybe) drop any trailing indices
857- sz = _remaining_size (J, size (A)) # compute trailing size (overlapping the final index)
860+ J, Jrem = IteratorsMD. split (I, Val{N})
861+ _to_subscript_indices (A, J, Jrem)
862+ end
863+ _to_subscript_indices (A:: AbstractArray , J:: Tuple , Jrem:: Tuple{} ) =
864+ __to_subscript_indices (A, indices (A), J, Jrem)
865+ # We allow partial linear indexing deprecation for OneTo arrays
866+ function __to_subscript_indices (A:: AbstractArray , :: Tuple{Vararg{OneTo}} , J:: Tuple , Jrem:: Tuple{} )
867+ @_inline_meta
868+ sz = _remaining_size (J, indices (A)) # compute trailing size (overlapping the final index)
858869 (front (J)... , _unsafe_ind2sub (sz, last (J))... ) # (maybe) extend the last index
859870end
871+ # After the partial linear indexing deprecation is removed, this next method can
872+ # become the new normal. For now, it's limited to non-OneTo arrays.
873+ function __to_subscript_indices (A:: AbstractArray , :: Tuple{AbstractUnitRange,Vararg{AbstractUnitRange}} , J:: Tuple , Jrem:: Tuple{} )
874+ @_inline_meta
875+ (J... , map (first, tail (_remaining_size (J, indices (A))))... )
876+ end
877+ _to_subscript_indices (A, J:: Tuple , Jrem:: Tuple ) = J # already bounds-checked, safe to drop
860878_to_subscript_indices {T,N} (A:: AbstractArray{T,N} , I:: Vararg{Int,N} ) = I
861879_remaining_size (:: Tuple{Any} , t:: Tuple ) = t
862880_remaining_size (h:: Tuple , t:: Tuple ) = (@_inline_meta ; _remaining_size (tail (h), tail (t)))
0 commit comments