title: Scala - not a case class nor does it have method .unapply
body: <p>I am quite new to Scala and got a few unresolved problems with the following code: </p>
  
  <pre><code>   object exprs{
        println("Welcome to the Scala worksheet")
  
        def show(e: Expr): String = e match {
          case Number(x) =&gt; x.toString
          case Sum(l, r) =&gt; show(l) + " + " + show(r)
        }
  
        show(Sum(Number(1), Number(44)))
      }
  
      trait Expr {
        def isNumber: Boolean
        def isSum: Boolean
        def numValue: Int
        def leftOp: Expr
        def rightOp: Expr
        def eval: Int = this match {
          case Number(n) =&gt; n
          case Sum(e1, e2) =&gt; e1.eval + e2.eval
        }
      }
  
      class Number(n: Int) extends Expr {
        override def isNumber: Boolean = true
  
        override def isSum: Boolean = false
  
        override def numValue: Int = n
  
        override def leftOp: Expr = throw new Error("Number.leftOp")
  
        override def rightOp: Expr = throw new Error("Number.rightOp")
      }
  
      class Sum(e1: Expr, e2: Expr) extends Expr {
        override def isNumber: Boolean = false
  
        override def isSum: Boolean = true
  
        override def numValue: Int = e1.eval + e2.eval
  
        override def leftOp: Expr = e1
  
        override def rightOp: Expr = e2
      }
  </code></pre>
  
  <p>I get the following errors:</p>
  
  <p><strong>Error:</strong> object Number is not a case class, nor does it have an unapply/unapplySeq member</p>
  
  <p><strong>Error:</strong> not found: value Sum</p>
  
  <p>How to resolve them? Thanks in advance</p>