title: scala: type mismatch error - found T, required String
body: <p>I'm learning scala, and this question may be stupid, but... why?</p>
  
  <p>For example, this is ok:</p>
  
  <pre><code>def matchList(ls: List[Int]): List[Int] = ls match {
    case 1 :: rest =&gt; rest
    case a :: b :: rest =&gt; (a + b) :: rest
    case _ =&gt; ls
  }
  
  matchList: (ls: List[Int])List[Int]
  </code></pre>
  
  <p>But function with type parameter does not compile:</p>
  
  <pre><code>def matchList[T](ls: List[T]): List[T] = ls match {
    case 1 :: rest =&gt; rest
    case a :: b :: rest =&gt; (a + b) :: rest
    case _ =&gt; ls
  }
  
  &lt;console&gt;:10: error: type mismatch;
  found   : T
  required: String
     case a :: b :: rest =&gt; (a + b) :: rest
  </code></pre>
  
  <p>Why?</p>