I am trying to define a method with the following signature:
def parse[T <: MyClass](statement: String): Try[List[T]] = {
My class is an abstract class:
sealed abstract class MyClass { }
case class MyClassChild(v: Int) extends MyClass
my parse
method returns a Success(List[MyClassChild])
But the compiler complains with the following error:
Error:(124, 19) type mismatch;
found : scala.util.Try[List[parser.MyClass]]
required: scala.util.Try[List[T]]
Why doesn't scala.util.Try[List[parser.MyClass]]
conform to scala.util.Try[List[T]]
, since T <: MyClass
?
Thank you