Different handing of "this" vs. "MyClass.this" in definite assignment

Archie Cobbs archie.cobbs at gmail.com
Tue Dec 6 16:05:51 UTC 2022


On Tue, Dec 6, 2022 at 9:49 AM Brian Goetz <brian.goetz at oracle.com> wrote:

> Are there some better warnings you could see coming out of this
> exploration?
>

Great idea.

What about simply warning any time "MyClass.this" is used in a situation
where it means the same thing as plain "this"?

Might make for a nice "lint" warning:

    MyClass.java:4: warning: [this-qual] unnecessary qualification of 'this'
            MyClass.this.x = 12;
                   ^

-Archie

-- 
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20221206/7766fe10/attachment.htm>


More information about the amber-dev mailing list