RFR: 8332600: javac uses record components source position during compilation [v2]

Vicente Romero vromero at openjdk.org
Fri Jul 12 20:45:54 UTC 2024


On Fri, 12 Jul 2024 13:03:02 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

>> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   review comments
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 1142:
> 
>> 1140:                             boolean paramIsVarArgs = (param.sym.flags_field & VARARGS) != 0;
>> 1141:                             if (!types.isSameType(param.type, recordFieldTypes.head) ||
>> 1142:                                     (recordComponents.head != null &&
> 
> I am afraid `recordComponents.head != null` (which is basically `recordComponents.isEmpty()`, I think) is probably insufficient here. Consider e.g.:
> 
> record R(int x, int x, int x) {}
> 
> 
> which will fail as `recordComponents` itself will be `null`, due to `tail` being `null`.
> 
> Looking at the last record component (`.last()`) might be one of the solutions?

I have changed the code a bit, I think it make more sense now, thanks for the comments

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20148#discussion_r1676441264


More information about the compiler-dev mailing list