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

JShell: support for switch expressions

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 12
    • Fix Version/s: 12
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Introduced In Version:
      12
    • Resolved In Build:
      b17

      Description

      Switch expressions in statements appear to work fine, but they are not recognized as expressions. For example:

      jshell> switch (day) {
         ...> case MONDAY, FRIDAY, SUNDAY -> 6;
         ...> case TUESDAY -> 7;
         ...> case THURSDAY, SATURDAY -> 8;
         ...> case WEDNESDAY -> 9;
         ...> }
      | Error:
      | not a statement
      | case MONDAY, FRIDAY, SUNDAY -> 6;
      | ^
      | Error:
      | not a statement
      | case TUESDAY -> 7;
      | ^
      | Error:
      | not a statement
      | case THURSDAY, SATURDAY -> 8;
      | ^
      | Error:
      | not a statement
      | case WEDNESDAY -> 9;
      | ^

      This is due to "switch" triggering the statement path of code analysis and parsing.

      Completion needs to be addressed as well. For example,

      switch (day) {
                 case MONDAY, FRIDAY, SUNDAY -> 6;
                 case TUESDAY -> 7;
                 case WEDNESDAY -> 9;
                 case THURSDAY, SATURDAY -> 8;
             } + 100

      does not include the "+ 100". This may be hard to address.

      -Robert

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rfield Robert Field
              Reporter:
              rfield Robert Field
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: