new TreeSet<>()
, that rely on natural ordering,
but their element type doesn't implement the Comparable
interface.
It's unlikely that such a collection will work properly.
A false positive is possible if the collection element is a non-comparable super-type,
but it's intended to hold only comparable sub-types. This is however error-prone.
It's better to narrow the collection element type or declare the super-type as Comparable
.
The inspection also reports cases when the collection element is a type parameter which is not declared as extends Comparable
.
You can suppress the warnings on type parameters using the provided option (for example, to keep the API compatibility).
New in 2018.3