blob: 8df079474315f21d6e055c26693ab3a42dd228a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
public class RecordPatternsPreview1ExhaustivenessError {
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>(C fst, D snd) -> System.out.println("a");
case Pair<I>(D fst, C snd) -> System.out.println("b");
case Pair<I>(I fst, C snd) -> 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) { }
|