Closed
Description
Minimized code
trait Box[+T]
case class Foo[+S](s: S) extends Box[S]
def unwrap2[A](b: Box[A]): A =
b match
case _: Foo[Int] => 0 // compiles, not ok
Output
Compiles with no warning, which is not OK.
Expectation
At least a warning about a pattern that cannot be checked at runtime should be emitted. The code shouldn't typecheck as well, but that's a secondary problem.