title: Type parameter inference in pattern matching
body: <p>I am trying to create some kind of heterogeneous map and came up with the following code</p>
  
  <pre><code>sealed trait Key[V]
  case object LongKey extends Key[Long]
  
  case class KeyValue[V](key: Key[V], value: V)
  
  object KeyValue {
    def values(key: Key[Long], kvs: List[KeyValue[_]]): List[Long] =
      kvs.collect {
        case KeyValue(LongKey, v) ⇒ v: Long // this compiles
        case KeyValue(`key`, v)   ⇒ v: Long // this doesn't
      }
  }
  </code></pre>
  
  <p>As <code>Key</code> is sealed and invariant I would have expected the 2 lines to be interchangeable.
  Why does the second case not compile?</p>
  
  <pre><code>...: type mismatch;
    found   : _$1 where type _$1
    required: Long
         case KeyValue(`key`, v) ⇒ v: Long
  </code></pre>