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

Compilation error thrown when long literal used with yield

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 15
    • Fix Version/s: 15
    • Component/s: tools
    • Subcomponent:
    • Resolved In Build:
      b15
    • Verification:
      Verified

      Description

      The below code is using long literal with yield and it should compile successfully. However, it reports compilation error.

      class Test {
          public void check() {
              var num = switch (1) {
                  case 1:
                      yield 0L; //Works with yield 0.0f, 0.0d and (long)0L
                  default:
                      yield 0;
              } ;
          }
      }

      Result:

      Test.java:5: error: not a statement
                                              case 1 : yield 0L;
                                                       ^
      Test.java:5: error: ';' expected
                                              case 1 : yield 0L;

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: