【发布时间】:2015-02-07 14:27:16
【问题描述】:
trait SomeClass {
...
}
trait AnotherClass[+V <: SomeClass] {
...
}
trait SomeAnotherClass[+V <: SomeClass] {
protected def someFunc[W >: V](anotherClass: AnotherClass[W]) = {
...
}
}
我收到此错误:
type arguments [W] do not conform to trait AnotherClass's type parameter bounds [+V <: SomeClass]
[error] protected def someFunc[W >: V](anotherClass: AnotherClass[W]) = ...
[error] ^
[error] one error found
当我执行 [W >: V <: SomeClass] 而不仅仅是 [W >: V] 时,我没有收到错误,但在这种情况下,它会隐藏变量。请帮忙,如何解决这个问题。
更新:
protected def someFunc(anotherClass: AnotherClass[V]) = {
...
}
我收到错误covariant type V occurs in contravariant position in type
【问题讨论】:
标签: scala scala-2.10