-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
area:experimentalarea:experimental:modularityIssues related to the modularity extension.Issues related to the modularity extension.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)
Description
Compiler version
3.7.2
Minimized code
//> using scala 3.7.2
import language.experimental.modularity
case class Event(tracked val payload: Payload)
enum Payload {
case Created()
}
val e = Event(Payload.Created())
def handleCreated(e: Event { def payload : Payload.Created}) = println(e.payload)
@main def run = e match {
case Event(payload: Payload.Created) => handleCreated(e.copy(payload = payload))
}
Output
Exception in thread "main" java.lang.ClassCastException: class Payload$Created cannot be cast to class scala.Function0 (Payload$Created and scala.Function0 are in unnamed module of loader 'app')
at demo$package$.handleCreated(demo.scala:12)
at demo$package$.run(demo.scala:15)
at run.main(demo.scala:14)
Expectation
Either a compile error, or just Created()
in the output.
Metadata
Metadata
Assignees
Labels
area:experimentalarea:experimental:modularityIssues related to the modularity extension.Issues related to the modularity extension.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)