Erroneous exhaustivity analysis for primitive patterns

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 23
    • Affects Version/s: None
    • Component/s: tools
    • None
    • b10

      Tests like the following, where the primitive pattern is not exhaustive on the selector type, are marked as "covering" the selector type erroneously:

      jshell> Number n = 42;
      n ==> 42

      jshell> switch (n) {
         ...> case int n when n == 0 -> 1;
         ...> case int n -> -1;
         ...> }
      $22 ==> -1

      jshell> Number n = Byte.valueOf((byte)0);
      n ==> 0

      jshell> switch (n) {
         ...> case int n when n == 0 -> 1;
         ...> case int n -> -1;
         ...> }
      | Exception java.lang.MatchException
      | at (#24:1)

      jshell> Object n = Byte.valueOf((byte)42);
      n ==> 42

      jshell> switch (n) {
         ...> case int n when n == 0 -> 1;
         ...> case int n -> -1;
         ...> }
      | Exception java.lang.MatchException
      | at (#29:1)

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

              Created:
              Updated:
              Resolved: