RFR: 8322810: Lambda expression types can't be classes [v7]
Vicente Romero
vromero at openjdk.org
Fri Apr 11 14:54:32 UTC 2025
On Fri, 11 Apr 2025 14:00:12 GMT, Vicente Romero <vromero 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).
>
> we could do that but I would prefer failing asap, as in `makeNotionalInterface` instead of waiting on `Types.findDescriptorInternal` to do the right thing, semantically we will get to the same point, what you are proposing seems to me like another way to get there but honestly I don't see the gain
also what would we do if one of the components is an annotation? technically the intersection is still an interface, we could set then the ANNOTATION flag but it seems like a forced move
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24548#discussion_r2039707277
More information about the compiler-dev
mailing list