title: If case class inheritance is prohibited, how to represent this?
body: <p>I am trying to create the case classes as explained in <a href="https://gleichmann.wordpress.com/2011/03/06/functional-scala-a-little-expression-language-with-algebraic-datatypes-and-pattern-matching/" rel="noreferrer">this article</a></p>
  
  <pre><code>sealed abstract case class Exp()
  case class Literal(x:Int) extends Exp
  case class Add(a:Exp, b:Exp) extends Exp
  case class Sub(a:Exp,b:Exp) extends Exp
  </code></pre>
  
  <p>However, I am getting the following error in IntelliJ. I understand why it is prohibited (<a href="https://stackoverflow.com/questions/30454354/why-case-to-case-inheritance-is-prohibited-in-scala">Why case-to-case inheritance is prohibited in Scala</a>). What is the alternate way here?</p>
  
  <pre><code>Error:(2, 13) case class Literal has case ancestor A$A34.A$A34.Exp, but case-to-case inheritance is prohibited. To overcome this limitation, use extractors to pattern match on non-leaf nodes.
  case class Literal(x:Int) extends Exp
             ^
  </code></pre>