Error messages technically true but that does not help if several cases have the same erasure
Jan Lahoda
jan.lahoda at oracle.com
Thu Jul 8 15:42:07 UTC 2021
Thanks, I've filled:
https://bugs.openjdk.java.net/browse/JDK-8270102
Jan
On 08. 07. 21 15:14, Maurizio Cimadamore wrote:
>
> On 07/07/2021 18:42, Remi Forax wrote:
>> The same is true for
>> List<?> list = null;
>> switch (list) {
>> case List l -> System.out.println("list2");
>> case List<?> l -> System.out.println("list1");
>> }
>>
>> which reports
>> PatternMatchingWrongDominated.java:18: error: duplicate total pattern
>> case List<?> l -> System.out.println("list1");
>> ^
>>
>>
>> I think javac should have a specific error if two cases have the same
>> erasure.
>
> I tend to agree, javac usually adds "detailed" messages, in
> parenthesis after the main issue. So this could be:
>
> ```
> PatternMatchingWrongDominated.java:18: error: duplicate total pattern
> case List<?> l -> System.out.println("list1");
> ^
> (List and List<?> have the same erasure)
>
> ```
>
>
> Maurizio
>
>
More information about the compiler-dev
mailing list