jdk-24/test/langtools/tools/javac/patterns/T8317300.java
2023-10-17 12:57:25 +00:00

25 lines
546 B
Java

/*
* @test /nodynamiccopyright/
* @bug 8317300
* @summary javac erroneously allows "final" in front of a record pattern
* @compile/fail/ref=T8317300.out -XDrawDiagnostics T8317300.java
*/
public class T8317300 {
record Foo (int x) {}
record Bar (Foo x) {}
void test1(Object obj) {
switch (obj) {
case final Foo(int x) -> {}
default -> {}
}
}
void test2(Object obj) {
switch (obj) {
case Bar(final Foo(int x)) -> {}
default -> {}
}
}
}