Closed
Description
object G {
final class X
final class Y
opaque type Foo = X & Y
object Foo {
def apply[F[_]](fa: F[X & Y]): F[Y & Foo] = fa
}
type Bar[A] = A match {
case X & Y => String
case Y => Int
}
def main(args: Array[String]): Unit = {
val a: Bar[X & Y] = "hello"
val i: Bar[Y & Foo] = Foo.apply[Bar](a)
val b: Int = i
println(b + 1)
}
}
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at scala.runtime.BoxesRunTime.unboxToInt(BoxesRunTime.java:103)
at G$.main(test.scala:30)
at G.main(test.scala)
Metadata
Metadata
Assignees
Labels
No labels