RFR: 8026369: javac potentially ambiguous overload warning needs an improved scheme [v4]

Archie L. Cobbs duke at openjdk.org
Sat Feb 25 16:07:25 UTC 2023


On Sat, 25 Feb 2023 04:05:29 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> Archie L. Cobbs has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Fix typo in one comment and clarify another.
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java line 2736:
> 
>> 2734:           .sorted(Comparator.comparing(e -> e.getKey().toString()))
>> 2735:           .map(Map.Entry::getValue)
>> 2736:           .peek(Collections::reverse)               // seems to help warning ordering
> 
> not sure about reversing the order here, it seems to me that if the order is reversed then the warning is shown in the first occurrence of a method instead of in the second which is the offending one. So for example for this code:
> 
> 
>     interface I1 {
>         void foo(Consumer<Integer> c);
>         void foo(IntConsumer c);
>     }
> 
> the warning is shown for the first method when I think it should be shown for the second which is the one introducing the ambiguity
> 
> EDIT, after your last commit, this comment now applies to: `methodGroups.forEach(Collections::reverse);`

The reversing was originally done in order to maintain consistency with the existing regression test outputs. But you are right - it results in visiting the methods backwards.

Fixed in e25ceced163.

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

PR: https://git.openjdk.org/jdk/pull/12645


More information about the compiler-dev mailing list