Does JLS tell if this program is legal?

Stephan Herrmann stephan.herrmann at berlin.de
Thu May 23 21:14:38 UTC 2024


Am 23.05.24 um 16:52 schrieb Dan Smith:
> [...] 
>>> 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.
>>
>> If I apply this strategy in ecj I get these pairs of supertypes of One<?> , Y
>> * One<?>, One<X>
>> * Super<? extends Inner<?>>, Super<Inner<X>>
>>
>> In both pairs we find a wildcard as a direct type argument and hence NO new constraint would be generated in §18.3.1.
>>
>> Is that what you have in mind?
> 
> Right. It is true, per the subtyping rules, that
> 
> One<?> <: Super<? extends Inner<?>>

with this, capture-super-then-upward-project seems to be the best option I have.
cool.


>> Does javac already implement this application of projection?
> 
> No, I don't believe so. The bug remains, it's something that needs to be addressed sometime.

So it remains a mystery to me, how exactly javac manages to accept the program 
at hand, but since we reached parity I'll stop worrying at this point :)

thanks to both of you!
Stephan


More information about the compiler-dev mailing list