2018-08-29 07:36:17 +00:00
|
|
|
/*
|
|
|
|
* @test /nodynamiccopyright/
|
|
|
|
* @bug 8206986
|
|
|
|
* @summary Adding switch expressions
|
2019-11-12 06:32:13 +00:00
|
|
|
* @compile/fail/ref=BadSwitchExpressionLambda.out -XDrawDiagnostics BadSwitchExpressionLambda.java
|
2018-08-29 07:36:17 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
class BadSwitchExpressionLambda {
|
|
|
|
|
|
|
|
interface SAM {
|
|
|
|
void invoke();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void m() {}
|
|
|
|
public static void r(SAM sam) {}
|
|
|
|
|
|
|
|
void test(int i) {
|
|
|
|
SAM sam1 = () -> m(); //ok
|
|
|
|
SAM sam2 = () -> switch (i) { case 0 -> m(); default -> m(); }; //not ok
|
|
|
|
r(() -> m()); //ok
|
|
|
|
r(() -> switch (i) { case 0 -> m(); default -> m(); }); //not ok
|
|
|
|
return switch (i) { case 0 -> m(); default -> m(); }; //not ok
|
|
|
|
}
|
|
|
|
}
|