RFR: 8369517: Compilation mismatch for equivalent lambda and method reference [v3]

Vicente Romero vromero at openjdk.org
Fri Oct 10 15:43:18 UTC 2025


> 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 method reference but not for the lambda. There should be no difference here (error in both cases)

Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:

  updating test

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/27737/files
  - new: https://git.openjdk.org/jdk/pull/27737/files/41783b0f..53f7d475

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=27737&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=27737&range=01-02

  Stats: 4 lines in 2 files changed: 0 ins; 0 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/27737.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/27737/head:pull/27737

PR: https://git.openjdk.org/jdk/pull/27737


More information about the compiler-dev mailing list