RFR: 8204610: Compiler confused by parenthesized "this" in final fields assignments
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Mon Jun 11 10:34:48 UTC 2018
On 09/06/18 01:17, Alex Buckley wrote:
> On 6/8/2018 6:55 AM, Maurizio Cimadamore wrote:
>> Basically, javac does not consistently skip parenthesis when enforcing
>> foward refs and DA/DU rules.
>
> I want to check that javac skips parentheses for `x` and `this.x` in
> DA/DU rules, but only for `x` in a forward field reference. At this
> time, JLS 8.3.3 detects a forward field reference only if made with a
> simple name; it's a bit late to expand that for JLS11, so I'm a bit
> alarmed by this unified treatment of variable access:
Javac is still implementing the same rule for forward references. E.g. a
forward reference is treated as such only if it's unqualified (e.g. in
the 'x' form); qualified access (this.x) will be allowed, as before.
I think my comment was a bit misleading - what I found is that there was
duplicated logic in javac where we checked multiple times whether some
'this.x' was ok to assign to; one was DA/DU (in Flow), another was a
custom check (in Attr); both are now using the same paren skipping
rules, to avoid spurious errors. In the long term we should consider
dropping the Attr check, which should be subsumed by DA/DU.
Maurizio
>
>> I decided to consolidate the 'is this a variable name, possibly
>> qualified by "this" ', into a separate TreeInfo routine, and call that
>> from Flow and Attr (it turned out that the wrong logic was applied in
>> both places).
>
> Alex
More information about the compiler-dev
mailing list