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

No compilation error reported when yield is used in incorrect context

    XMLWordPrintable

Details

    • b28
    • 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

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

                Dates

                  Created:
                  Updated:
                  Resolved: