List of case classes doesn't match T <: Serializable

Viewed 130

Given a type definition T <: Serializable, why doesn't this match everything that is serializable, including a List of serializable instances?

I.e. given:

case class Bar()

def foo[T <: Serializable](param1: T) = println(param1)

foo(Bar())
foo(List(Bar()))

The compiler gives the following error:

Error:(6, 2) inferred type arguments [List[A$A15.this.Bar]] do not conform to method foo's type parameter bounds [T <: Serializable]

The case class extends Serializable, so does List - why doesn't a list of Bars match the type?

1 Answers
Related