-
Bug
-
Resolution: Fixed
-
P4
-
None
-
b15
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8316725 | 21.0.2 | Angelos Bimpoudis | P4 | Resolved | Fixed | b02 |
Regardless of the presence of a guard, if intra-case dominance is violated, the switch needs to be rejected.
public class Test {
void test(Object obj) {
switch (obj) {
case Integer _, CharSequence _, String _ when obj.hashCode() > 0 -> {
}
default -> throw new IllegalStateException("Unexpected
value: " + obj);
}
}
}
https://mail.openjdk.org/pipermail/amber-spec-experts/2023-August/003910.html
public class Test {
void test(Object obj) {
switch (obj) {
case Integer _, CharSequence _, String _ when obj.hashCode() > 0 -> {
}
default -> throw new IllegalStateException("Unexpected
value: " + obj);
}
}
}
https://mail.openjdk.org/pipermail/amber-spec-experts/2023-August/003910.html
- backported by
-
JDK-8316725 Intra-case dominance check fails in the presence of a guard
- Resolved