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

No compilation error reported when yield is used in incorrect context

    Details

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

      Backports

        Description

        The below code should throw a compilation error as yield is used in incorrect context. However, the compilation goes through successfully.

        interface TestIntf {
            void foo(int[] a);
        }

        public class SwitchTest {

            public static void main(String[] args) {
                TestIntf expr = (yield a) -> {
                    System.out.println(a.length);
                };
                expr.foo(new int[]{12, 3, 45});
            }
        }

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jlahoda Jan Lahoda
                  Reporter:
                  vkhatri Vinod Khatri
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: