【发布时间】:2013-08-02 07:28:39
【问题描述】:
为什么这个函数不编译?
case class MyType(n: Int)
def intersection(s1: Set[MyType], s2: Set[_ <: MyType]) =
(s1 & s2)
我收到以下错误:
错误:类型不匹配;找到:设置 [_$1] 类型 _$1 _ <: MyType。 (SLS 3.2.10) (w & r)
有没有一种简单的方法可以在不使用 asInstanceOf 的情况下将第二个参数“提升”为 Set[MyType] 类型?
【问题讨论】: