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

yield <primitive-type>.class not parsed correctly.

    XMLWordPrintable

Details

    • b02

    Backports

      Description

        Consider:
        ---
        public class SwitchPrimitive {
             private void test(String s) {
                Class<?> c = switch (s) {
                     case "": yield int.class;
                     default: yield null;
                };
             }
        }
        ---

        This fails with:
        ---
        $ javac /tmp/SwitchPrimitive.java
        /tmp/SwitchPrimitive.java:4: error: not a statement
                     case "": yield int.class;
                              ^
        /tmp/SwitchPrimitive.java:4: error: ';' expected
                     case "": yield int.class;
                                   ^
        /tmp/SwitchPrimitive.java:4: error: not a statement
                     case "": yield int.class;
                                       ^
        3 errors
        ---

        while it should compile without errors.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                  Created:
                  Updated:
                  Resolved: