Closed
Description
minimized code
class A
class B extends A
class C extends A
object Foo {
private[this] class Bar[+T](var x: T)
def foo: B = {
val barB: Bar[B] = new Bar(new B)
val barA: Bar[A] = barB
barA.x = new C
barB.x
}
}
Foo.foo
result
java.lang.ClassCastException
expectation
Variance error is reported.
variations
private
is also broken in Dottyprivate[this]
is also broken in Scalacprivate
is detected in Scalac