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

Should ignore nested lambda bodies during overload resolution

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b23
    • Verification:
      Verified

      Backports

        Description

        javac apparently does some partial checking of lambda bodies in nested invocations during overload resolution, and uses the results to consider some methods inapplicable. This is incorrect -- the nested lambda body should not influence applicability at all.

        <T> T apply(UnaryOperator<T> op, T arg) { return op.apply(arg); }

        class B { B x() { return this; } }
        class C {}

        void m(B arg) { System.out.println("B"); }
        void m(C arg) { System.out.println("C"); }

        m(apply(arg -> arg.x(), null)); // ambiguous, as expected
        m(apply(arg -> new B(), null)); // expected: ambiguous; actual: chooses m(B)

        (I believe this is a holdover from earlier overload resolution prototypes, which were designed to make use of partial information in the lambda body.)

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                vromero Vicente Arturo Romero Zaldivar
                Reporter:
                dlsmith Dan Smith
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: