RFR: 8204610: Compiler confused by parenthesized "this" in final fields assignments
John Rose
john.r.rose at oracle.com
Tue Jun 12 05:31:12 UTC 2018
On Jun 11, 2018, at 7:41 PM, Liam Miller-Cushon <cushon at google.com> wrote:
>
> Treating equivalent unqualified and qualified this accesses differently feels surprising to me in a way that, say, treating `(true?this:this).x` and `this.x` differently doesn't.
Yes, it’s a special move for setting blank finals. Back in the day, we considered not allowing qualified this in that position, as a simpler design, but it would have made it impossible for constructors to use the same names for both fields and arguments (or temps). I personally prefer to use consistent names for recurring values, and believe it is good practice. So couldn’t imagine *not* allowing such naming consistency in constructors which after all are at the heart of classes. That and no other reason is why we have the funny alias this.x for x when x is DU, so it can be initialized from a parameter of the same name.
More information about the compiler-dev
mailing list