Skip to content

Commit fd5e5c8

Browse files
Regression test for eclipse-jdt#4094 (eclipse-jdt#4096)
1 parent cc28bcd commit fd5e5c8

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10525,4 +10525,45 @@ public static void main(String argv[]) {
1052510525

1052610526
"Ok!");
1052710527
}
10528+
// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4094
10529+
// Error on Eclipse 4.36 when compiling Record with field usage
10530+
public void testIssue4094() {
10531+
this.runConformTest(
10532+
new String[] {
10533+
"X.java",
10534+
"""
10535+
public class X {
10536+
public static void main(String [] args) {
10537+
System.out.println(ClassB.B);
10538+
}
10539+
}
10540+
""",
10541+
"ClassB.java",
10542+
"""
10543+
import java.util.List;
10544+
import java.util.function.Predicate;
10545+
10546+
10547+
public class ClassB {
10548+
10549+
private final Predicate<RecordA> predicate;
10550+
10551+
public static final ClassB B = new ClassB(recordA -> recordA.test.isEmpty());
10552+
10553+
public ClassB(Predicate<RecordA> predicate) {
10554+
this.predicate = predicate;
10555+
}
10556+
10557+
public String toString() {
10558+
return "ClassB instance";
10559+
}
10560+
10561+
record RecordA(List<Object> test, Integer i) {
10562+
}
10563+
}
10564+
"""
10565+
},
10566+
10567+
"ClassB instance");
10568+
}
1052810569
}

0 commit comments

Comments
 (0)