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

Regression: stuck expressions do not behave correctly

XMLWordPrintable

    • b120
    • Verified

      Since the fix for JDK-8078093 there has been a regression in the behavior for stuck expressions. For example, this program fails to compile:

      import java.util.function.Consumer;
      import java.nio.ByteBuffer;

      class Foo {
          Foo(Consumer<ByteBuffer> cb) {
          }

          public static void main(String[] args) {
              Foo foo = new Foo((b -> System.out.println(asString(b))));
          }

          static String asString(ByteBuffer buf) {
              return null;
          }
      }

      But compiles if the parenthesis are removed from around the lambda.

      Also, this other program:

      interface Foo1 {
         Object m(String s);
      }

      interface Foo2 {
         String m(String s);
      }

      class Test {
         void m(Foo1 f1) { }
         void m(Foo2 f2) { }

         void test() {
            m(x->"");
            m((x->""));
         }
      }

      Only reports one ambiguity error instead of two.

            mcimadamore Maurizio Cimadamore
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: