- Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
area:pattern-matchingitype:bugitype:soundnessSoundness bug (it lets us compile code that crashes at runtime with a ClassCastException)Soundness bug (it lets us compile code that crashes at runtime with a ClassCastException)
Description
//> using scala "3.7.3" trait A[+T]: def x: T trait B[+T] extends A[T]: def y: T object Troll extends A[Int] with B[Any]: def x: Int = 0 def y: Any = "" def f[T](a: A[T]): T = a match { case b: B[T] => b.y // compiles without warning case _ => a.x } @main def t(): Unit = val a: A[Int] = Troll val i: Int = f(a) // ClassCastException println(i + 1)in case b: B[T] the type argument T cannot be checked at runtime. The compiler does not report an unchecked warning.
Metadata
Metadata
Assignees
Labels
area:pattern-matchingitype:bugitype:soundnessSoundness bug (it lets us compile code that crashes at runtime with a ClassCastException)Soundness bug (it lets us compile code that crashes at runtime with a ClassCastException)