Does JLS tell if this program is legal?

Dan Smith daniel.smith at oracle.com
Wed May 22 00:13:32 UTC 2024


> On May 21, 2024, at 12:49 PM, Stephan Herrmann <stephan.herrmann at berlin.de> wrote:
> 
> * Super<Inner<?>> is a supertype of T / One<?> (directly)

Note that "is a supertype" here isn't true though:

Is One<?> <: Super<Inner<?>>
Is One<CAP> <: Super<Inner<?>>
Is Super<Inner<CAP>> <: Super<Inner<?>>
Is Inner<CAP> = Inner<?>
false

This is related to
https://bugs.openjdk.org/browse/JDK-8016196

Unfortunately, JLS doesn't specify a way to map from subtypes to supertypes when wildcards are involved. (It's one of those unexplained corners of the type system.)

I've got a solution in my mind that involves the upward projection operation we introduced in 4.10.5: capture, find the supertype, then project away the capture variable. But there are details to work out.


More information about the compiler-dev mailing list