title: Pattern type is incompatible with expected type in textbook example
body: <p>I'm working through the Essential Scala textbook from Underscore, and when I try to use one of the examples from the command line using the :load command I get errors. [edit] I said command line, I meant console.</p>
  
  <p>I have put the code into a file by itself, and then have tried to use it using the :load command.</p>
  
  <pre class="lang-scala prettyprint-override"><code>sealed trait IntList {
    def product: Int =
      this match {
        case End =&gt; 1
        case Pair(hd, tl) =&gt; hd * tl.product
      }
  }
  case object End extends IntList
  final case class Pair(head: Int, tail: IntList) extends IntList
  </code></pre>
  
  <p>I expected the code to compile and be usable, but I get these messages:</p>
  
  <pre><code> error: pattern type is incompatible with expected type;
   found   : End.type
   required: IntList
        case End =&gt; 1
  </code></pre>
  
  <p>and</p>
  
  <pre><code>error: constructor cannot be instantiated to expected type;
   found   : Pair
   required: IntList
        case Pair(hd, tl) =&gt; hd * tl.product
  </code></pre>