Open
Description
Compiler version
Scala compiler version 3.7.3-RC1
Minimized code
object A:
val p: { type X >: Any <: Nothing } = p // ok
@main def Test =
val y: Int = "hi" : A.p.X // java.lang.ClassCastException: class java.lang.String cannot be cast to class scala.runtime.Nothing
Expectation
I would expect this to type check (for recursive vals in objects) but diverge at run-time.
Note that we report an error for recursive vals when in a def:
def A =
val p: { type X >: Any <: Nothing } = p
// error: p is a forward reference extending over the definition of p