My code
object TestApp extends App {
class A[T <: Ordered[T]] {
def check(f: T, s: T) = f > s
}
object A {
def apply[T] = new A[T]
}
A[String].check("ab", "aa")
}
throws an exception:
Error:(13, 9) type arguments [T] do not conform to class A's type parameter bounds [T <: Ordered[T]]
def apply[T] = new A[T]
^
But I don't understand why. For me, it seems ok. I have a class with type variable bounded with Ordered. In companion object, I'm trying to create an instance of A. But I'm not sure if my companion object has an access to the type variable of class A.
How can I fix it?