When Comparable<? extends T>
appears it means you have an instance of Comparable
that can be compared to one (unknown) subtype of T
, not that it can be compared to any subtype of T.
But you don't need that, because a Comparable<T>
can compare itself to any subtype of T
anyway, e.g. a Comparable<Number>
can compare itself to a Comparable<Double>
.
So try:
interface A<T> extends Comparable<T> {
// ...
}
or
interface A<T extends Comparable<T>> extends Comparable<A<T>> {
// ...
}
depending on whether you need to be able to compare instances of T
in order to implement your compareTo
method.