Open EugeneFlesselle opened 4 months ago
Another variation I came up with before I realized this issue already existed:
class W[+Y]
object W:
type Extract[A] = A match
case W[x] => x
trait Base[+T]:
val w: T
def take(x: W.Extract[w.type]): Int
class SubInt extends Base[W[Int]]:
val w: W[Int] = W[Int]()
def take(x: W.Extract[w.type]): Int = x
@main def run =
val b: Base[W[Any]] = SubInt()
val i: Int = b.take("") // ClassCastException
Compiler version
3.5.0-RC1
Minimized code
This is another instance of #19746 except the prefix is a trait value instead of a function parameter.