RFR: 8334248: Invalid error for early construction local class constructor method reference [v3]
Archie Cobbs
acobbs at openjdk.org
Mon Jun 17 18:31:13 UTC 2024
On Mon, 17 Jun 2024 18:04:17 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> But, interestingly, the error is issued very late (in Lower rather than in Attr). This has to do with the logic that sets AttrContext::ctorPrologue: this field is set to false as soon as we encounter a local class.
Any ugliness is surely due to my incomplete understanding of compiler internals. The assumption is that a new `Env` is created when we encounter a new class declaration, and so the `ctorPrologue` flag is only valid for the current class. So that would make sense that it is reset inside the local class (new `Env` there). Consistent with that, the `Resolve.findVar()` method recurses up through each enclosing `Env`'s and checks the corresponding `ctorPrologue` flag, which corresponds to the scope in which the variable is ultimately found, for being in an early construction context But this may be incomplete or skipped in the `EarlyLocalClass.this` example... ?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/19705#issuecomment-2174107816
More information about the compiler-dev
mailing list