title: Scala: How to make a protected method accessible to sub-classes (on other instances)?
body: <p>I'm trying to do something like this:</p>
  
  <pre class="lang-scala prettyprint-override"><code>trait A[Out] {
      protected def foo(): Out
  }
  
  trait B extends A[Int]
  
  class WrapperB(b: B) extends B {
      override protected def foo(): Int = b.foo() + 1
  }
  </code></pre>
  
  <p>This won't compile, as <code>WrapperB</code> has no access to <code>b.foo()</code>.</p>
  
  <p>There are a few ways to resolve this, but these won't work for me:</p>
  
  <ol>
  <li>Make <code>foo</code> public: won't work, because I want it to stay <code>protected</code>.</li>
  <li>Use a package scope: won't work, because I intend to have many <code>B</code>s in different packages.</li>
  </ol>
  
  <p>Is there any other way?</p>