RFR: 8356551: Javac rejects receiver parameter in constructor of local class in early construction context
Archie Cobbs
acobbs at openjdk.org
Mon May 12 14:36:51 UTC 2025
On Sun, 11 May 2025 10:12:02 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> My feeling is that at this point we should just attribute `Foo` -- and leave `this` alone. That is, `this` is just an extra syntactic token that is used to denote the receiver parameter name. Attributing it as `Foo.this` causes the compiler to think it's an outer `this` access, which this is not. So let's just type-check the type (and leave `this` off to the side) ? After all this code only wants to make sure the type before `.this` makes sense for the context in which the receiver parameter appears.
I tried out that approach in [this branch](https://github.com/openjdk/jdk/compare/master...archiecobbs:jdk:JDK-8356551-alt). I'm reaching the limits of my grasp so this may not be the simplest way to do this. AFAICT we still have to (a) assign some type/symbol to the parameter expression (to avoid NPE later) and (b) do the static check stuff.
Let me know which version you prefer, or any other thoughts.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25153#issuecomment-2872828788
More information about the compiler-dev
mailing list