title: Better type checking on match in Scala
body: <pre><code>scala&gt; class A
  defined class A
  
  scala&gt; class B
  defined class B
  
  scala&gt; val a: A = new A
  a: A = A@551510e8
  
  scala&gt; a match {
       | case _: B =&gt; println("unlikely")
       | case _ =&gt; println("no match")
       | }
  no match
  </code></pre>
  
  <p>In the example above shouldn't the compiler tell me that one of the cases can never match? A slightly more complicated example recently caught me out, leading to what felt like an unnecessary bug that should have been caught by the compiler.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Just to be clearer about the question. Is this impossible in Scala for some reason I can't see? (I can understand if the types were using generics and type erasure was causing problems but this looks pretty straight forward.) And if this is not impossible are there legitimate reasons this isn't in Scala? If not when will it be added? ;)</p>