title: Self type inheritance in scala
body: <p>Say I have the following traits:</p>
  
  <pre><code>trait A
  
  trait B { this: A =&gt; }
  
  trait C extends B // { this: A =&gt; }
  </code></pre>
  
  <p>Compiler error: <code>illegal inheritance;  self-type C does not conform to B's selftype B with A</code><br>
  As expected if I uncomment the self type annotation, the compiler is happy.</p>
  
  <p>I think it's quite obvious why C also needs this self type. What I don't understand why it can not "inherit" it from A if the compiler could already figure out that it's needed?  </p>
  
  <p>I think it could reduce the verbosity when you use self types with complicated hierarchies, especially if you mix in a big bunch of traits, each of them having its own self type.</p>
  
  <p>I guess probably there is a good reason for the current behavior, I just could not find/figure out what it is.  </p>
  
  <p>At first I thought it might be related to mixin linearization, but it seems to me it does not play here (even if I had more traits mixed in with more complicated self types).  </p>
  
  <p>Would it cause ambiguities in some cases? If so, why can't it work when there is no ambiguity?</p>
  
  <p>Or is it related to some difficulties in proper implementation of it?</p>
  
  <p>I could find some discussions about the topic (like <a href="http://scala-programming-language.1934581.n4.nabble.com/self-type-is-not-inherited-td1999536.html" rel="noreferrer">self type is not inherited</a>), but they mostly just state the problem and conclude that's how it is without too much explanation and/or a solution (if it exists).</p>