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.

RecordPatternsPreview1ExhaustivenessError.java 592B

12345678910111213141516171819202122
  1. public class RecordPatternsPreview1ExhaustivenessError {
  2. static Pair<I> p2 = new Pair<>(new C(), new D());
  3. public static void main(String[] args) {
  4. exhaustiveSwitch();
  5. }
  6. static void exhaustiveSwitch() {
  7. switch (p2) {
  8. case Pair<I>(C fst, D snd) -> System.out.println("a");
  9. case Pair<I>(D fst, C snd) -> System.out.println("b");
  10. case Pair<I>(I fst, C snd) -> System.out.println("c");
  11. }
  12. }
  13. }
  14. class A { }
  15. class B extends A { }
  16. sealed interface I permits C, D { }
  17. final class C implements I { }
  18. final class D implements I { }
  19. record Pair<T>(T x, T y) { }