From 100595c151885ccccb867d73fdf926512816a1f3 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Wed, 10 Sep 2025 10:43:16 +0200 Subject: [PATCH 1/2] `ReadOnly`: define only single-argument methods for `size` and `axes` On nightly Julia, this change prevents two sysimage invalidations triggered by defining two-argument `axes`. --- src/readonly.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/readonly.jl b/src/readonly.jl index 037e1f9d..490c4c62 100644 --- a/src/readonly.jl +++ b/src/readonly.jl @@ -13,10 +13,10 @@ ReadOnly(x::ReadOnly) = x Base.getproperty(x::ReadOnly, s::Symbol) = Base.getproperty(parent(x), s) @inline Base.parent(x::ReadOnly) = getfield(x, :parent) -for i in [:length, :first, :last, :eachindex, :firstindex, :lastindex, :eltype] +for i in [:length, :first, :last, :eachindex, :firstindex, :lastindex, :eltype, :axes, :size] @eval Base.@propagate_inbounds @inline Base.$i(x::ReadOnly) = Base.$i(parent(x)) end -for i in [:iterate, :axes, :getindex, :size, :strides] +for i in [:iterate, :getindex, :strides] @eval(Base.@propagate_inbounds @inline Base.$i(x::ReadOnly, y...) = Base.$i(parent(x), y...)) end From 8d8022e4170856f386ce461cb2e0c336a038d9eb Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Wed, 10 Sep 2025 10:50:16 +0200 Subject: [PATCH 2/2] `ReadOnly`: do not add the `eltype` method * new types are not supposed to define `eltype` on instances * new subtypes of `AbstractArray` are not supposed to add methods to `eltype` --- src/readonly.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/readonly.jl b/src/readonly.jl index 490c4c62..00eacc3c 100644 --- a/src/readonly.jl +++ b/src/readonly.jl @@ -13,7 +13,7 @@ ReadOnly(x::ReadOnly) = x Base.getproperty(x::ReadOnly, s::Symbol) = Base.getproperty(parent(x), s) @inline Base.parent(x::ReadOnly) = getfield(x, :parent) -for i in [:length, :first, :last, :eachindex, :firstindex, :lastindex, :eltype, :axes, :size] +for i in [:length, :first, :last, :eachindex, :firstindex, :lastindex, :axes, :size] @eval Base.@propagate_inbounds @inline Base.$i(x::ReadOnly) = Base.$i(parent(x)) end for i in [:iterate, :getindex, :strides]