As you might noticed, I've not opened the vote yet. Partly because I was
improving
my implementation as well as the RFC itself (added some words about the
inheritance
implications), but the main reason is that a question arise in the
meanwhile.

Namely, "write-once" properties could in principle support covariance. That
is, a subclass
would be allowed to tighten the property type that is inherited from the
parent class.
It would be a slight change compared to regular properties that are
invariant.

All this would be possible because of the quasi-immutable nature of
"write-once" properties:
they are generally expected to be assigned to only once, in the constructor
- which is exempt from
LSP checks.

There is a gotcha though... In practice, "write-once" properties could be
written from places
other than the constructor. Although there might not be many practical
use-cases for it,
the infamous setter injection is certainly one (as shown at
https://3v4l.org/DQ3To), in which
case property covariance would be a problem.

That's why I'm curious about some additional input on the matter. Do you
think
covariance of "write-once" properties is worth to have even though there
might be
some edge-cases when it can't be supported perfectly? I'll include this
topic a bit later
in the RFC as well. In the worst case it could be added to the "Future
Scope" section
because - and correct me if I'm wrong - we can also add support for it
later since it would be
a non-breaking change.

Cheers,
Máté

Reply via email to