RFR: 8322810: Lambda expression types can't be classes [v7]

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Apr 11 09:43:33 UTC 2025


On Fri, 11 Apr 2025 08:29:22 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> Instead, it should set the `INTERFACE` flag only if the class component of the intersection is `Object` (as the JLS says).

Note: in principle one might claim that it should be `types.makeIntersectionType` to do this -- but there are complications, in that the method that creates the intersection type is not allowed to to call `flags()` as this method is also called from `ClassReader` at a very delicate time. There's a boolean `allInterfaces` flag that is used there, which we could use to set the optional `INTERFACE` flag on the intersection, but this relies on the assumption that `allInterfaces` is only set if the first bound is an interface (e.g. this tells the code if an extra `Object` supertype has to be injected into the intersection) -- which is not exactly what you want.

What we might do is to say that if `allInterfaces` is set, OR if the `firstExplicitBound` is `syms.objectType` then we treat this as `INTERFACE`. But if this is too difficult to do in general, then it's ok to keep the `Attr` code manually setting the `INTERFACE` flag depending on the bound (as there's no completion to worry about there).

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24548#discussion_r2039190216


More information about the compiler-dev mailing list