Sealing interface with generics in eclipse

176 Views Asked by At

The following is legal (i.e. I can compile it) and works in Java 15 with preview features enabled (in eclipse 2020-09)

public sealed interface Quantity<T> permits QuantityImpl { }
public record QuantityImpl<T extends Number>(T value) implements Quantity<T> { }

public class Play {
    public static void main(String[] args) {
        Quantity<Float> q = new QuantityImpl<>(3.0f);
        System.out.println(q instanceof Quantity);
    }
}

However, eclipse is complaining in Quantity.java at ... permits QuantityImpl. When hovering over QuantityImpl one can read:

Permitted type QuantityImpl does not declare Quantity<T> as direct super interface

Is this, even though it compiles, a valid complaint or a bug in eclipse?

0

There are 0 best solutions below