[英]Bounded generic type as case class parameter
I'm attempting to allow a case class parameter to be generic: 我试图允许case类参数是通用的:
trait RequestEntityMarshallable
case class ImportConfirmMessage(bla: String) extends RequestEntityMarshallable
case class Req(entity: _ <: RequestEntityMarshallable)
However I get a unbound wildcard type
compilation error at entity: _ <: RequestEntityMarshallable
. 但是我在entity: _ <: RequestEntityMarshallable
处收到unbound wildcard type
编译错误。 What is the correct way to do this? 正确的方法是什么?
做这个
case class Req[A <: RequestEntityMarshallable](entity: A)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.