You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The null path p below can be used to collapse the subtyping lattice through bad bounds. This snippet was found jointly with Ross Tate who asked whether our recent soundness result for DOT would carry over in presence of null values.
objectworldextendsApp {
traitA { typeL <: Nothing }
traitB { typeL >: Any}
deftoL(b: B)(x: Any): b.L = xvalp: BwithA = null// we can create a value of type Nothingprintln(toL(p)("hello"): Nothing)
// at runtime: java.lang.ClassCastException: java.lang.String cannot be cast to scala.runtime.Nothing$// variation on a theme...defcast[T,U](x: T): U = toL(p)(x)
println(cast[Int,String](1) + "hello")
// at runtime: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Stringprintln(cast[String,Int => Int]("hello")(1))
// at runtime: java.lang.ClassCastException: java.lang.String cannot be cast to scala.Function1
}
The text was updated successfully, but these errors were encountered:
The
null
pathp
below can be used to collapse the subtyping lattice through bad bounds. This snippet was found jointly with Ross Tate who asked whether our recent soundness result for DOT would carry over in presence ofnull
values.The text was updated successfully, but these errors were encountered: