title: scala generic conversion A[T] => B[T]
body: <p>I am trying to use generics to not lose the subtype of the implementation.
  It's not totally clear to me how to search for this question although I believe it has as a name.
  I've a trait named conf and some implementations (where WB is an instance of Params):</p>
  
  <pre><code>trait Conf[P &lt;: Params]
  
  class ConfInstance extends Conf[WB]
  </code></pre>
  
  <p>now I want that a backend can convert this type parameters into a different class like this:</p>
  
  <pre><code>trait Coder[P &lt;: Params]
  class AABBCC(conf: Conf[WB]) extends Coder[WB]
  
  def backend[P &lt;: Params](conf: Conf[P]): Coder[P] = {
      conf match {
          case abcConf: ConfInstance =&gt; new AABBCC(abcConf)
      }
  </code></pre>
  
  <p>but the compiler complains with : "Expression of type AABBCC" doesn't conform to expected type Coder[P]"</p>
  
  <p>What I tryed was to add an asInstanceOf[Coder[P]] but I don't like this solution.</p>
  
  <p>So which is the correct way to do this conversion? </p>