RFR: 8349754: Invalid "early reference" error when class extends an outer class [v2]
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu Feb 13 18:46:09 UTC 2025
On Thu, 13 Feb 2025 18:38:10 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Thanks, that is a nice simplification.
>>
>> From what I can tell we still need to make an exception for the `Foo.this.x` case, otherwise this example would fail:
>>
>> class Early {
>> int x;
>> class Sub extends Early {
>> Sub() {
>> Early.this.x = 3;
>> super();
>> }
>> }
>> }
>>
>> Trying to explain this to myself: The current class here is `Foo`, and `Foo.this.x` does indeed refer to a member of class `Foo`. But it refers to a different _instance_ of class `Foo` from the one under construction.
>>
>> I suppose this question of "Which _instance_ of class S are we talking about?" only comes up in the compiler in the corner case when a class has S as both a superclass and an outer class, so there's not really "first class" support for answering this question, like there is for answering the question "Is x a member of S?".
>>
>> Fixed in 589e6d7d2fc.
>
>> From what I can tell we still need to make an exception for the `Foo.this.x`
>
> Sure - I was referring to the "simple name" part of the affair :-)
> Trying to explain this to myself: The current class here is `Foo`, and `Foo.this.x` does indeed refer to a member of class `Foo`. But it refers to a different _instance_ of class `Foo` from the one under construction.
I will also re-read the JLS carefully, to make sure this is covered
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23545#discussion_r1955045911
More information about the compiler-dev
mailing list