On Fri, 23 Jan 2026 11:12:48 GMT, Maurizio Cimadamore <[email protected]> 
wrote:

>> Vicente Romero has updated the pull request with a new target base due to a 
>> merge or a rebase. The incremental webrev excludes the unrelated changes 
>> brought in by the merge/rebase. The pull request contains three additional 
>> commits since the last revision:
>> 
>>  - adding test case
>>  - Merge branch 'lworld' into JDK-8373916
>>  - 8373916: [lworld] TypeName.this.FieldName should be restricted in early 
>> construction context
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 1397:
> 
>> 1395:                         } else if (mode == 
>> PrologueVisitorMode.THIS_CONSTRUCTOR &&
>> 1396:                                 
>> TreeInfo.isThisOrSelectorDotThis(subtree) &&
>> 1397:                                 TreeInfo.isExplicitThisReference(
> 
> It's a bit sad we have to add an extra check when in reality 
> `isExplicitThisReference` already does what we need -- but is too broad (and 
> confusingly named) as it also picks up `super`.
> 
> For this PR we're fine. In the future I'd like to see 
> `isExplicitThisReference` split into two parts:
> * `isExplicitThisReference`
> * `isExplicitSuperReference`
> And then a method can be defined which does the OR:
> * `isExplicitThisOrSuperReference
> 
> Then your check could only use one of them, whereas the rest of javac can use 
> the OR method.

yes probably the name can be improved but the method tries to determine if the 
current AST is a reference to the `this` instance of the current class being 
constructed and this could happen with ASTs containing `super` or `this` so 
most of the time we want to check both

-------------

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/1899#discussion_r2721784893

Reply via email to