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

Only guards of boolean type and value true should be considered to be unguarded

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 19
    • 19
    • tools
    • None

      Consider:
      ---
      sealed interface Intf permits A, B {}
      final static class A implements Intf {}
      final static class B implements Intf {}
      private int test(Intf selectorParam, Boolean b) {
          return switch (selectorParam) {
                  case A a when b -> 2;
                  case B b -> 1;
              };
      }
      ---

      This used to compile as exhaustive, although it should not.

            jlahoda Jan Lahoda
            jlahoda Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: