-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8314423: Multiple patterns without unnamed variables
8314216: Case enumConstant, pattern compilation fails Reviewed-by: jlahoda
- Loading branch information
Showing
6 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* @test /nodynamiccopyright/ | ||
* @bug 8314216 | ||
* @summary Multiple patterns without unnamed variables | ||
* @compile/fail/ref=T8314216.out -XDrawDiagnostics --enable-preview --source ${jdk.version} T8314216.java | ||
*/ | ||
|
||
public class T8314216 { | ||
enum X {A, B} | ||
|
||
void test(Object obj) { | ||
switch (obj) { | ||
case X.A, Integer _ -> System.out.println("A or Integer"); | ||
case String _, X.B -> System.out.println("B or String"); | ||
default -> System.out.println("other"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
T8314216.java:13:23: compiler.err.invalid.case.label.combination | ||
T8314216.java:14:28: compiler.err.invalid.case.label.combination | ||
- compiler.note.preview.filename: T8314216.java, DEFAULT | ||
- compiler.note.preview.recompile | ||
2 errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* @test /nodynamiccopyright/ | ||
* @bug 8314423 | ||
* @summary Multiple patterns without unnamed variables | ||
* @compile/fail/ref=T8314423.out -XDrawDiagnostics T8314423.java | ||
* @compile --enable-preview --source ${jdk.version} T8314423.java | ||
*/ | ||
|
||
public class T8314423 { | ||
record R1() {} | ||
record R2() {} | ||
|
||
static void test(Object obj) { | ||
switch (obj) { | ||
case R1(), R2() -> System.out.println("R1 or R2"); | ||
default -> System.out.println("other"); | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
test(new R1()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
T8314423.java:15:24: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.unnamed.variables) | ||
1 error |
4331193
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review
Issues