trait Rendered
trait TemplateRendered extends Rendered
trait Media {
def send[T <: Rendered](cooked:T)
}
case class EmailMedia() extends Media {
override def send(cooked:TemplateRendered) {} // compile error this line
}
I want to have a Media template with a send() method that accepts a subclass Rendered object. In the concrete classes (EmailMedia) I want to lock that down to a particular subclass of Rendered, or TemplateRendered in this case. (i.e. make the type in the class more restrictive/specific than the type in the trait)
How can I do that?
The attempt here wasn't liked by the compiler. Tried this too:
case class EmailMedia() extends Media {
override def send[T <: TemplateRendered](cooked:T) {}
}