jdk-24/test/langtools/tools/javac/T8312163.java
Aggelos Biboudis c9d23c3940 8315532: Compiler Implementation for Unnamed Variables & Patterns
8317221: Implementation for javax.lang.model for Unnamed Variables & Patterns

Co-authored-by: Jan Lahoda <jlahoda@openjdk.org>
Co-authored-by: Maurizio Cimadamore <mcimadamore@openjdk.org>
Co-authored-by: Gavin Bierman <gbierman@openjdk.org>
Co-authored-by: Brian Goetz <briangoetz@openjdk.org>
Co-authored-by: Joe Darcy <darcy@openjdk.org>
Co-authored-by: Aggelos Biboudis <abimpoudis@openjdk.org>
Reviewed-by: jlahoda, mcimadamore
2023-10-30 10:28:48 +00:00

58 lines
1.3 KiB
Java

/*
* @test /nodynamiccopyright/
* @bug 8312163
* @summary Crash in dominance check when compiling unnamed patterns
* @compile/fail/ref=T8312163.out -XDrawDiagnostics T8312163.java
*/
public class T8312163 {
sealed interface A permits B {}
record B() implements A {}
record Rec(A a, A b) {}
public void test(Rec r)
{
switch (r) {
case Rec(_, _): break;
case Rec(_, B()): // dominated
}
switch (r) {
case Rec(_, B()): break;
case Rec(_, _):
}
switch (r) {
case Rec(_, _): break;
case Rec(_, A a): // dominated
}
switch (r) {
case Rec(_, A a): break;
case Rec(_, _): // dominated
}
// duplicated unnamed patterns with unnamed pattern variables for reference
switch (r) {
case Rec(var _, var _): break;
case Rec(var _, B()): // dominated
}
switch (r) {
case Rec(var _, B()): break;
case Rec(var _, var _):
}
switch (r) {
case Rec(var _, var _): break;
case Rec(var _, A a): // dominated
}
switch (r) {
case Rec(var _, A a): break;
case Rec(var _, var _): // dominated
}
}
}