Closed
Description
trait Foo[X >: Any <: Nothing]
@main def Test = (None: Option[Foo[?]]) match {
case _: Option[Foo[t]] =>
val unsound: Nothing = (5 : Any) : t
(unsound : Unit => Unit).apply(())
}
The problem seems to be that pattern matching lets us name a type argument which does not correspond to a type member with known good bounds. In DOT, we would not be able to refer to t
, so the issue would not show up.
Fixes we have thought of so far:
- Disallowing classes with bad bounds on type parameters
- Disallowing pat-mat from naming types with bad bounds / only letting pat-mat name types with bounds that are known to be good
- Disallowing pat-mat from naming type arguments which are not top-level