Следующее:
trait Foo {
type T
val foo: T
}
trait Bar extends Foo {
type T = this.type
val foo = this
}
выдает ошибку компилятора:
<console>:8: error: overriding value foo in trait Foo of type Bar.this.T;
value foo has incompatible type
val foo = this
^
Однако, если я изменю последнюю строку на:
val foo: this.type = this
, она компилируетсябез ошибок.
Почему я должен здесь явно указывать тип?Я уже говорил, что тип foo
должен быть T
, а T
должен быть this.type
.Тип this
не this.type
?