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

Better error recovery for broken patterns in switch

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 17
    • 17
    • tools
    • None
    • b29

    Backports

      Description

        As reported here:
        https://mail.openjdk.java.net/pipermail/core-libs-dev/2021-June/078693.html

        The error recovery could be improved in cases like:
        Object obj = ...;
        switch (obj) {
             case String -> {}
        }

        $ javac --enable-preview -source 17 /tmp/Test.java
        /tmp/Test.java:4: error: cannot find symbol
                     case String -> {}
                          ^
          symbol: variable String
          location: class Test

        Could produce an error suggesting there should be a pattern instead of a simple identifier.

        Attachments

          Issue Links

            Activity

              People

                jlahoda Jan Lahoda
                jlahoda Jan Lahoda
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: