假设我们定义一个接口为:识别两个类型通配符相同
trait Foo[A] {
val value: A
def perform(v: A): Unit
}
和编译此代码:
val n: Foo[_] = null
n.perform(n.value)
它看起来很完美......但我们得到了一个神秘的错误:
error: type mismatch;
found : n.value.type (with underlying type _$1)
required: _$1
n.perform(n.value)
^
那么......为什么会发生这种情况呢?我知道如何解决这个问题。我只是好奇。谢谢!
感谢您的详细解释! – 2014-11-24 10:52:41