title: Case to case inheritance in Scala
body: <p>I have an abstract class which I extend and make numerous case classes. Now I want to copy instances of those case classes just changing first parameter, so I use case class' <code>copy</code> method. </p>
  
  <p>Since I have to do this for all case classes that have been extended from common abstract class, rather than doing it for all, I tried to make it general and made the abstract class a case class. </p>
  
  <p>Then Scala gives me this:</p>
  
  <blockquote>
    <p>case class Octopus has case ancestor Organism, but case-to-case inheritance is prohibited. To overcome this limitation, use extractors to pattern match on non-leaf nodes.</p>
  </blockquote>
  
  <p>Code: </p>
  
  <pre><code>abstract class Organism(legs: Int)
  case class Octopus(override val legs: Int, weight: Double, ...)
  case class Frog(override val legs: Int, ...)
  def clone(o: Organism) = o.copy(legs = -1)
  </code></pre>
  
  <p>This is what I want to do. But if I can't make the <code>clone</code> method work, then I will have to do copying for both <code>Octopus</code> &amp; <code>Frog</code>.</p>
  
  <p>Any suggestions, to decrease this verbosity?</p>