mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
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
This commit is contained in:
parent
3f4b55c4df
commit
b3b644438e
121 changed files with 4753 additions and 268 deletions
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8206986
|
||||
* @summary Adding switch expressions
|
||||
* @compile/fail/ref=BadSwitchExpressionLambda.out -XDrawDiagnostics --enable-preview -source 12 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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue