Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsInSwitch/UnconditionalDestructuringAndDefaultIn19Java.java
Alexandr Suhinin c1c07294bd IDEA-298282: report error if switch has default case element and unconditional deconstruction
GitOrigin-RevId: a4ee7da8085f322c4211ffb3bb7e4898a0b73f36
2022-07-20 19:59:30 +00:00

33 lines
1.0 KiB
Java

record RecordInterface(I x, I y) {}
sealed interface I permits C, D {}
final class C implements I {}
final class D implements I {}
public class Totality {
RecordInterface recordInterface;
void test(){
switch (recordInterface){
case <error descr="'switch' has both a total pattern and a default label">RecordInterface(I x, I y)</error> -> {}
case <error descr="'switch' has both a total pattern and a default label">default</error> -> {}
}
switch (recordInterface){
case RecordInterface(I x, I y) r when true-> {}
case default -> {}
}
switch (recordInterface){
case RecordInterface(I x, I y) -> {}
}
switch (recordInterface){
case <error descr="'switch' has both a total pattern and a default label">RecordInterface r</error> -> {}
<error descr="'switch' has both a total pattern and a default label">default</error> -> {}
}
switch (recordInterface){
case RecordInterface(I x, C y) -> {}
case default -> {}
}
}
}