I am trying to declare a method in an abstract class that receives an array of type T. As such:
abstract class Circle[-T] extends Shape[T] {
def draw(points: Array[T]): Unit
}
The problem I am getting is that the Scala compiler complains with:
contravariant type T occurs in an invariant position in type Array [T] of value
So, is there a way to solve this other than the following?
def draw[U <: T](points: Array[U]): Unit
As a side note, I also need to extend this class in Java.
source
share