Учитывая это:
abstract class ViewPresenterPair {
type V <: View
type P <: Presenter
trait View {self: V =>
val presenter: P
}
trait Presenter {self: P =>
var view: V
}
}
Я пытаюсь определить реализацию следующим образом:
case class SensorViewPresenter[T] extends ViewPresenterPair {
type V = SensorView[T]
type P = SensorPresenter[T]
trait SensorView[T] extends View {
}
class SensorViewImpl[T](val presenter: P) extends SensorView[T] {
presenter.view = this
}
class SensorPresenter[T] extends Presenter {
var view: V
}
}
Что дает мне следующие ошибки:
error: illegal inheritance;
self-type SensorViewPresenter.this.SensorView[T] does not conform to SensorViewPresenter.this.View's selftype SensorViewPresenter.this.V
trait SensorView[T] extends View {
^
<console>:13: error: type mismatch;
found : SensorViewPresenter.this.SensorViewImpl[T]
required: SensorViewPresenter.this.V
presenter.view = this
^
<console>:16: error: illegal inheritance;
self-type SensorViewPresenter.this.SensorPresenter[T] does not conform to SensorViewPresenter.this.Presenter's selftype SensorViewPresenter.this.P
class SensorPresenter[T] extends Presenter {
^
Я не понимаю, почему. В конце концов, V
это просто псевдоним для SensorView[T]
, и пути одинаковы, так как это может не соответствовать?