Skip to content

Missing unchecked type argument warning #24322

@lrytz

Description

@lrytz
//> 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

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions