Skip to content

Commit 26c80c8

Browse files
authored
ReadOnly: do not add single-argument methods to eachindex, etc (#653)
1 parent 15ec056 commit 26c80c8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/readonly.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ ReadOnly(x::ReadOnly) = x
1313
Base.getproperty(x::ReadOnly, s::Symbol) = Base.getproperty(parent(x), s)
1414
@inline Base.parent(x::ReadOnly) = getfield(x, :parent)
1515

16-
for i in [:length, :first, :last, :eachindex, :firstindex, :lastindex, :axes, :size]
16+
for i in [:length, :first, :last, :axes, :size]
1717
@eval Base.@propagate_inbounds @inline Base.$i(x::ReadOnly) = Base.$i(parent(x))
1818
end
1919
for i in [:iterate, :getindex, :strides]
2020
@eval(Base.@propagate_inbounds @inline Base.$i(x::ReadOnly, y...) = Base.$i(parent(x), y...))
2121
end
2222

23+
Base.eachindex(i::IndexLinear, x::ReadOnly) = eachindex(i, parent(x))
24+
Base.eachindex(i::IndexCartesian, x::ReadOnly) = eachindex(i, parent(x))
25+
2326
Base.unsafe_convert(x::Type{Ptr{T}}, A::ReadOnly) where T = Base.unsafe_convert(x, parent(A))
2427
Base.elsize(::Type{ReadOnly{T,N,V}}) where {T,N,V} = Base.elsize(V)
2528
Base.@propagate_inbounds @inline Base.setindex!(x::ReadOnly, v, ind::Vararg{Integer}) = if v == getindex(parent(x), ind...)

0 commit comments

Comments
 (0)