2
考慮到與類型參數的性狀,以及一個抽象類型的成員訪問:自我類型不能類型成員
trait Foo[A] {
def schoko(f: A) : Unit
}
trait Bar {
type A
def foo: Foo[A]
}
trait X
trait ConcreteBar extends Bar {
final type A = X
}
是否有任何變化得到任何下列工作的:
trait Mixin extends ConcreteBar {
_: Foo[A] => // "not found: type A"
def foo = this
}
trait Mixin[A] extends Bar {
_: Foo[A] =>
def foo = this // "found: Mixin[A] with Foo[A] required: Foo[Mixin.this.A]"
}
trait Mixin[A1] extends ConcreteBar {
_: Foo[A1] =>
type A = A1 // "error: overriding type A in trait ConcreteBar, which equals X"
def foo = this
}