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

Erroneous exhaustivity analysis for primitive patterns

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 23
    • None
    • tools
    • None
    • b10

    Description

      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)

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: