RFR: 8294942: Compiler implementation for Record Patterns (Second Preview)
Aggelos Biboudis
abimpoudis at openjdk.org
Sun Oct 30 18:52:34 UTC 2022
On Thu, 27 Oct 2022 13:21:58 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
>> test/langtools/tools/javac/patterns/NewCaseStructureTest.java line 283:
>>
>>> 281: case Integer i when i > 0 -> 0;
>>> 282: case 0 -> 0;
>>> 283: case Integer i -> 0;
>>
>> This case is not needed, right?
>
> Well, omitting the unconditional case would make the switch non-exhaustive. While that would not be a blocker for a testcase that verifies that error are reported, I think it is cleaner to avoid unrelated errors in the source code.
I checked: the exhaustivity errors are not reported after these points. The dominance check short circuits the structure test. But I see what you mean: while the tests do not isolate the error, they are type correct modulo dominance. Sounds good to me.
-------------
PR: https://git.openjdk.org/jdk/pull/10814
More information about the compiler-dev
mailing list