jdk-24/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.java
Joe Darcy bf2d27c5a4 8219254: Update explicit uses of latest source/target in langtools tests to a property
8219256: Update javac diags tests to use properties

Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Reviewed-by: jjg, jlahoda, darcy, iignatyev
2019-02-21 10:29:16 -08:00

25 lines
703 B
Java

/*
* @test /nodynamiccopyright/
* @bug 8206986
* @summary Adding switch expressions
* @compile/fail/ref=BadSwitchExpressionLambda.out -XDrawDiagnostics --enable-preview -source ${jdk.version} BadSwitchExpressionLambda.java
*/
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
}
}