On Fri, May 31, 2024, at 5:45 PM, Claude Pache wrote: >> Le 31 mai 2024 à 18:08, Larry Garfield <la...@garfieldtech.com> a écrit : >> >> However, this also brings up another interesting issue: readonly properties >> (in 8.3) DO allow redeclaration, essentially adjusting the property scope >> (the class that declares it) to make the visibility check pass. That is, the >> definition of the class it is private to changes, which is different from >> how inheritance works elsewhere. When the parent writes to the same >> property, a special check is needed to verify the two properties are >> related. All that special casing effectively means that readonly in 8.4 >> wouldn't really be "write once + private(set)", but "write once + >> private(set) - final", which is... just kinda screwy. That means our >> options are: >> >> * A BC break on readonly (not allowing it to be overridden) >> * Make readonly an exception to the implicit final. >> * Just don't allow readonly with aviz after all. > > Another possible option is: > > * Make readonly be `protected(set)` by default. > > That would weaken the originally intended semantics of readonly, but in > a compatible and acceptable way? > > —Claude
Only sort of compatible. It would allow readonly props to be redefined, and wouldn't break any existing code, I think... but it would mean any time you use readonly, suddenly a child class can come along and mess with it out from under you. In practice that's likely not a common concern, but it is a behavior change. I think it's possible (I need to confirm with Ilija), if we want that slight BC break, but I don't know if we do. --Larry Garfield