You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RecordPatternsPreview1Error.java 746B

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