Integrated: 8322810: Lambda expression types can't be classes

Vicente Romero vromero at openjdk.org
Fri May 2 20:46:52 UTC 2025


On Wed, 9 Apr 2025 14:03:03 GMT, Vicente Romero <vromero at openjdk.org> wrote:

> Currently javac is accepting code like:
> 
> 
> class Test {
>     void m() {
>         var r = (Test & Runnable) () -> System.out.println("Hello, World!");
>     }
> }
> 
> 
> according to: `4.9 Intersection Types` a notional interface can't be induced here as one of the components is a class different from `j.l.Object`
> 
> With this fix this code pattern will be rejected with a compiler error
> 
> TIA

This pull request has now been integrated.

Changeset: 56468c42
Author:    Vicente Romero <vromero at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/56468c42bef8524e53a929dc2ae603cff05b55e3
Stats:     77 lines in 6 files changed: 71 ins; 3 del; 3 mod

8322810: Lambda expression types can't be classes

Reviewed-by: mcimadamore

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

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


More information about the compiler-dev mailing list