Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8314632

Intra-case dominance check fails in the presence of a guard

XMLWordPrintable

    • b15

        Regardless of the presence of a guard, if intra-case dominance is violated, the switch needs to be rejected.

        public class Test {
            void test(Object obj) {
               switch (obj) {
                  case Integer _, CharSequence _, String _ when obj.hashCode() > 0 -> {
                  }
                  default -> throw new IllegalStateException("Unexpected
        value: " + obj);
               }
            }
        }

        https://mail.openjdk.org/pipermail/amber-spec-experts/2023-August/003910.html

              abimpoudis Angelos Bimpoudis
              abimpoudis Angelos Bimpoudis
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: