-
Bug
-
Resolution: Fixed
-
P3
-
21, 22, 23
-
b12
Consider code like:
---
package test;
public class Test {
sealed interface A permits T, U {}
sealed interface B permits V, W {}
static final class T implements A {}
static final class U implements A {}
static final class V implements B {}
static final class W implements B {}
final static record R(A a, B b) {}
static int r(R r) {
return switch (r) {
case R(A a, V b) -> 1;
case R(T a, B b) -> 2;
case R(U a, W b) -> 3;
};
}
}
---
This should be exhaustive, but an error is reported:
---
$ javac /tmp/Test.java
/tmp/Test.java:20: error: the switch expression does not cover all possible input values
return switch (r) {
^
1 error
---
---
package test;
public class Test {
sealed interface A permits T, U {}
sealed interface B permits V, W {}
static final class T implements A {}
static final class U implements A {}
static final class V implements B {}
static final class W implements B {}
final static record R(A a, B b) {}
static int r(R r) {
return switch (r) {
case R(A a, V b) -> 1;
case R(T a, B b) -> 2;
case R(U a, W b) -> 3;
};
}
}
---
This should be exhaustive, but an error is reported:
---
$ javac /tmp/Test.java
/tmp/Test.java:20: error: the switch expression does not cover all possible input values
return switch (r) {
^
1 error
---