blob: c4a89b8d69f46214e1d9ffeae095df670e63e495 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
/**
* This was not working as expected in ECJ after the initial Java 19 merge from the JDT Core main line,
* see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450.
*/
public class RecordPatternsPreview1Error {
public static void main(String[] args) {
erroneousTest1(new Box<>("A"));
erroneousTest2(new Box<>("B"));
}
static void erroneousTest1(Box<Object> bo) {
if (bo instanceof Box(var s)) { // Javac error: raw deconstruction patterns are not allowed
System.out.println("I'm a box");
}
}
static void erroneousTest2(Box b) {
if (b instanceof Box(var t)) { // Javac error: raw deconstruction patterns are not allowed
System.out.println("I'm a box");
}
}
}
record Box<T>(T t) {}
|