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

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 19
    • Fix Version/s: 19
    • Component/s: tools
    • Labels:
      None

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: