Consider the following code/switch:
```
package test;
public class Test {
private int test(Root r) {
return switch (r) {
case Root(R2(R1 _), R2(R1 _)) -> 0;
case Root(R2(R1 _), R2(R2 _)) -> 0;
case Root(R2(R2 _), R2(R1 _)) -> 0;
};
}
sealed interface Base {}
record R1() implements Base {}
record R2(Base b1) implements Base {}
record Root(R2 b2, R2 b3) {}
}
```
This switch is obviously not exhaustive, as there's a case missing for `Root(R2(R2 _), R2(R2 _))`. But, javac currently is not particularly helpful in finding this missing case:
```
$ javac test/Test.java
.../test/Test.java:4: error: the switch expression does not cover all possible input values
return switch (r) {
^
1 error
```
It would be better if javac produced an error message pointing out the missing possibility/ies, at least in some cases.
```
package test;
public class Test {
private int test(Root r) {
return switch (r) {
case Root(R2(R1 _), R2(R1 _)) -> 0;
case Root(R2(R1 _), R2(R2 _)) -> 0;
case Root(R2(R2 _), R2(R1 _)) -> 0;
};
}
sealed interface Base {}
record R1() implements Base {}
record R2(Base b1) implements Base {}
record Root(R2 b2, R2 b3) {}
}
```
This switch is obviously not exhaustive, as there's a case missing for `Root(R2(R2 _), R2(R2 _))`. But, javac currently is not particularly helpful in finding this missing case:
```
$ javac test/Test.java
.../test/Test.java:4: error: the switch expression does not cover all possible input values
return switch (r) {
^
1 error
```
It would be better if javac produced an error message pointing out the missing possibility/ies, at least in some cases.