I am trying to return a subclass of an abstract generic class in Scala but it won't compile. I get Expression of type A doesn't conform to to expected type B. here is the code I am using:
abstract class AA[T](val var1: String){
def doSomething(): T;
}
class BB(override val var1: String) extends AA[Int](var1){
override def doSomething(): Int = {
return 5
}
}
object Factory {
def create(v: String) : AA[Any] = {
return new BB("5") // this is the error
}
}
What should be the signature of create()?
Thanks