aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2023-11-27 11:14:04 +0700
committerAlexander Kriegisch <Alexander@Kriegisch.name>2023-11-27 11:14:04 +0700
commit93511aeb022abcf550124f7e7eb4ed5f7d917cd2 (patch)
treece5e2edca11ddbc4bd1be7178528675e2db18e47
parent37f3f6c11135d0d6cac6ec2511f8d2baefdc8457 (diff)
downloadaspectj-93511aeb022abcf550124f7e7eb4ed5f7d917cd2.tar.gz
aspectj-93511aeb022abcf550124f7e7eb4ed5f7d917cd2.zip
Add missing file RecordPatternsPreview1ExhaustivenessOK1.java for JDK 21
This file was missing, which did not trigger an error in CI builds, because AllTestsAspectJ1921 was not part of the AllTests19 suite before. The latter will be fixed in the next commit. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
-rw-r--r--tests/features1921/java21/RecordPatternsPreview1ExhaustivenessOK1.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/features1921/java21/RecordPatternsPreview1ExhaustivenessOK1.java b/tests/features1921/java21/RecordPatternsPreview1ExhaustivenessOK1.java
new file mode 100644
index 000000000..5be25f80a
--- /dev/null
+++ b/tests/features1921/java21/RecordPatternsPreview1ExhaustivenessOK1.java
@@ -0,0 +1,34 @@
+public class RecordPatternsPreview1ExhaustivenessOK1 {
+ static Pair<A> p1 = new Pair<>(new A(), new B());
+ static Pair<I> p2 = new Pair<>(new C(), new D());
+
+ public static void main(String[] args) {
+ exhaustiveSwitch();
+ }
+
+ static void exhaustiveSwitch() {
+ switch (p2) {
+ case Pair<I>(I i, C c) -> System.out.println("x");
+ case Pair<I>(I i, D d) -> System.out.println("y");
+ // Redundant default clause no longer necessary after fix of https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455.
+ // Old version with default clause see features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java.
+ // default -> System.out.println("z");
+ }
+
+ switch (p2) {
+ case Pair<I>(C c, I i) -> System.out.println("a");
+ case Pair<I>(D d, C c) -> System.out.println("b");
+ case Pair<I>(D d1, D d2) -> System.out.println("c");
+ // Redundant default clause no longer necessary after fix of https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455.
+ // Old version with default clause see features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java.
+ // default -> System.out.println("d");
+ }
+ }
+}
+
+class A { }
+class B extends A { }
+sealed interface I permits C, D { }
+final class C implements I { }
+final class D implements I { }
+record Pair<T>(T x, T y) { }