Skip to content

No warning on typecase pattern involving a case class #11178

Closed
@abgruszecki

Description

@abgruszecki

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions