-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
itype: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)stat:needs triageEvery issue needs to have an "area" and "itype" labelEvery issue needs to have an "area" and "itype" label
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
Metadata
Metadata
Assignees
Labels
itype: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)stat:needs triageEvery issue needs to have an "area" and "itype" labelEvery issue needs to have an "area" and "itype" label