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

JShell: support for switch expressions

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 12
    • 12
    • tools
    • None
    • 12
    • 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

              rfield Robert Field (Inactive)
              rfield Robert Field (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: