Scala : class[T] extends T?
<p>Question : How could I achieve the following pattern in scala or Java ?</p>

<pre><code>trait A
case class B[Base](...) extends A with Base
</code></pre>

<p>this is allowed in C++ : </p>

<pre><code>template &lt;class Base&gt;
class B : public Base, public A
</code></pre>

<hr>

<p>Here is why I want to do it :</p>

<p>I have two abstract syntax trees :  <code>ComplexForm</code> and <code>SimpleForm</code></p>

<p>and I have a type for lists : <code>case class L[T](list : List[T]) extends Complex Form with T</code></p>

<p>now, <code>L[SimpleForm]</code> should <code>extends SimpleForm with ComplexForm</code>
but <code>L[ComplexForm]</code> should only <code>extend ComplexForm</code></p>

<p>I need to be able to pattern match agains all <code>L[T]</code> at once in order to avoid duplication.</p>