blob: 208b3d574f2f224ea4c376b0c1bfb0be509aba25 [file] [log] [blame]
/*
* @test /nodynamiccopyright/
* @bug 8206986 8226510
* @summary Verify than a switch that does not yield a value is rejected.
* @compile/fail/ref=EmptySwitch.out -XDrawDiagnostics -XDshould-stop.at=FLOW EmptySwitch.java
*/
public class EmptySwitch {
private void print(EmptySwitchEnum t) {
(switch (t) {
}).toString();
(switch (t) {
default -> throw new IllegalStateException();
}).toString();
(switch (t) {
default: throw new IllegalStateException();
}).toString();
(switch (0) {
case 0: yield "";
default:
}).toString();
(switch (0) {
case 0 -> { yield ""; }
default -> { }
}).toString();
}
enum EmptySwitchEnum {
}
}