on implementing state components as a first class concept
brian.goetz at oracle.com
Thu Apr 25 21:34:42 UTC 2019
Records are classes. Any code inside the class body can reference the
fields, such as explicit constructors, implementations of equals(), or
other methods. They will expect to see fields that have the expected names.
>> One way to overcome the same name issue could be to generate a
>> synthetic name for the private field, kind or $stateComponent, that
>> way the compiler won't have any issue attributing both field-like
>> entities. The problem with this is that user code added to the
>> record, will use the state component name so that user code will need
>> to be rewritten, at parser time?, so that it refer to the synthetic
>> name given to the private field. This is not a big deal but could
>> generate other side-effects.
> The build-in fields in the proposal area private and final and are
> implicitly set in the generated portions of the default constructor.
> The accessor methods are public and have a matching name.
> Are there use-cases where direct access to the private fields in
> constructors is necessary?
More information about the amber-dev