forked from openjdk/jdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8314578: Non-verifiable code is emitted when two guards declare patte…
…rn variables in colon-switch
- Loading branch information
Showing
3 changed files
with
41 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* @test /nodynamiccopyright/ | ||
* @bug 8314578 | ||
* @summary Parsing of erroneous patterns succeeds | ||
* @compile/fail/ref=T8314578.out -XDrawDiagnostics T8314578.java | ||
*/ | ||
|
||
public class T8314578 { | ||
record R1() {} | ||
record R2() {} | ||
|
||
static void test(Object o) { | ||
switch (o) { | ||
case R1() when o instanceof String s: | ||
case R2() when o instanceof Integer i: | ||
System.out.println("hello: " + i); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
static void test2(Object o) { | ||
switch (o) { | ||
case R1() when o instanceof String s: | ||
System.out.println("hello: " + s); | ||
case R2() when o instanceof Integer i: | ||
System.out.println("hello: " + i); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} |
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,4 @@ | ||
T8314578.java:14:18: compiler.err.flows.through.from.pattern | ||
T8314578.java:15:18: compiler.err.flows.through.to.pattern | ||
T8314578.java:27:18: compiler.err.flows.through.to.pattern | ||
3 errors |