title: Self-type mismatch in Scala
body: <p>Given this:</p>
  
  <pre><code>abstract class ViewPresenterPair {
    type V &lt;: View 
    type P &lt;: Presenter
  
    trait View {self: V =&gt;
      val presenter: P
    }
  
    trait Presenter {self: P =&gt;
      var view: V
    }
  }
  </code></pre>
  
  <p>I am trying to define an implementation in this way:</p>
  
  <pre><code>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
    }
  }
  </code></pre>
  
  <p>Which gives me the following errors:</p>
  
  <pre><code>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 {
                                       ^
  &lt;console&gt;:13: error: type mismatch;
   found   : SensorViewPresenter.this.SensorViewImpl[T]
   required: SensorViewPresenter.this.V
          presenter.view = this
                           ^
  &lt;console&gt;: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 {
                                            ^
  </code></pre>
  
  <p>I don't understand why. After all, <code>V</code> is just an alias for <code>SensorView[T]</code>, and the paths are the same, so how can it not conform?</p>