Actually, I'm not sure I see the problem.

The well formedness rules in the JLS say that it must be:

FooOrderable? <: [T:=FooOrderable?]Orderable<T>

(that is, the actual type argument must be a subtype of the bound where type-variables are replaced for the type-parameter)

If you expand that you get:

FooOrderable? <: Orderable<FooOrderable?>

Which seems trivially true (the supertype of FooOrderable is the same as that of FooOrderable? and is Orderable<FooOrderable?>).

Can we please clarify as to what the problem is?

Maurizio

On 13/05/2019 17:46, Brian Goetz wrote:
The question about "what about F-bounds" is a good one; thanks for raising this.  Needs further thought.

But, while I agree you've raised a problem, I think it's a pretty big leap to the "solution" you propose.  So let's table that (re-)proposal pending a deeper understanding of the problem, and its relation to the other requirements.

On 5/10/2019 4:50 PM, Remi Forax wrote:
Let's say i have this interface:
   interface Orderable<T extends Orderable<T>> {
    boolean lessThan(T t);
   }

and i want my inline class to implement it:
   @__inline__ class FooOrderable implements Orderable<FooOrderable?> {
     ...
     @Override
     public boolean lessThan(FooOrderable? foo) {
       return false;
     }
   }

how i'm suppose to write it given that the bound of FooOrderable as to be Orderable<FooOrderable> but Orderable<FooOrderable> is not a valid type ?

I think that we have moved from a generic of an inline class is unsafe (because of the NPEs) to it's an illegal type a little to fast.

I believe we should emit an unchecked warning instead with the definition of unchecked to be widened to include not only the CCEs but also the NPEs.

Rémi

Reply via email to