aboutsummaryrefslogtreecommitdiffstats
path: root/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2022-12-21 12:57:44 +0100
committerAlexander Kriegisch <Alexander@Kriegisch.name>2022-12-21 12:57:44 +0100
commit5239ae0480d4f623aa9c9491b6bf75e3e568cc89 (patch)
treef6bd5d5e80275c25770282eb5b8de4f22db8c6cd /tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java
parent9be61fe259dfd3340050f0c4d80ee9e9555583e1 (diff)
downloadaspectj-5239ae0480d4f623aa9c9491b6bf75e3e568cc89.tar.gz
aspectj-5239ae0480d4f623aa9c9491b6bf75e3e568cc89.zip
Add tests for Java 19 record patterns
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java')
-rw-r--r--tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java b/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java
new file mode 100644
index 000000000..4153d5021
--- /dev/null
+++ b/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java
@@ -0,0 +1,28 @@
+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");
+ }
+
+ 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");
+ }
+ }
+}
+
+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) { }