jdk-24/test/langtools/tools/javac/switchextra/SwitchArrowBrokenConstant.java
Jan Lahoda b3b644438e 8206986: Compiler support for Switch Expressions (Preview)
8207405: Compiler Tree API support for Switch Expressions (Preview)

Support for switch expression, switch with rules and multiple constants for cases.

Reviewed-by: jjg, mcimadamore, vromero
2018-08-29 09:36:17 +02:00

33 lines
768 B
Java

/*
* @test /nodymaticcopyright/
* @bug 8206986
* @summary Verify reasonable errors are produced when neither ':' nor '->'
* is found are the expression of a case
* @compile/fail/ref=SwitchArrowBrokenConstant.out -source 12 --enable-preview -Xlint:-preview -XDrawDiagnostics SwitchArrowBrokenConstant.java
*/
public class SwitchArrowBrokenConstant {
private String likeLambda(int i) {
switch (i) {
case (a, b) -> {}
}
return switch (i) {
case (a, b) -> {}
};
switch (i) {
case a;
}
return switch (i) {
case a;
};
switch (i) {
default ;
}
return switch (i) {
default ;
};
}
}