Compilation mismatch for equivalent lambda and method reference

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P4
    • 26
    • Affects Version/s: 25, 26
    • Component/s: tools
    • None

      Given the following test case:

      ```
      import java.util.function.Supplier;
      interface Main {
          interface X<T> {
              X<T> self();
          }

          static X<?> makeX() {return null;}

          static <R> X<R> create(Supplier<? extends R> supplier) {return null;}

          static X<X<?>> methodRef() {
              return create(Main::makeX).self();
          }

          static X<X<?>> lambda() {
              return create(() -> makeX()).self();
          }
      }
      ```

      javac reports an error for the lambda, but not for the method reference. There should be no difference here (error in both cases)

      reported by Tagir at: https://mail.openjdk.org/pipermail/compiler-dev/2025-October/031680.html

            Assignee:
            Vicente Arturo Romero Zaldivar
            Reporter:
            Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: