"compose_attributes" is apparently called before attributes are composed
Solution 1:
Attribute composition is not the time when attributes are added to the class; rather, it is the time at which:
- We commits to a particular set of attributes for the class, and communicate this to the underlying runtime (usually MoarVM), which calculates a memory layout for the object
- we tell each
Attribute
object to compose itself, which is its trigger to generate accessors,handles
-related methods, and so forth
I'm not clear on what you are intend to achieve, in so far as attributes are externally readonly by default anyway, and so it'd make more sense perhaps to produce an error if somebody defines an rw
one on something declared frozen
. If you do want to modify attributes, you'd probably have more luck overriding add_attribute
and tweaking the way the attribute works at that point (for example, something like method add_attribute($obj, $attr) { callwith($obj, $attr.clone(:!rw, :!has_accessor)) }
may achieve what you want).