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
This is in all versions of scala, it's not a regression or anything.
classCell[T](x0: T) {
typeU=Tvarx1:U= x0
}
objectTest {
valstr:Cell[String] =newCell("a")
valother:Cell[Int] =newCell(0)
defmain(args: Array[String]):Unit= {
List(str, other) foreach (_.x1 =newAnyRef)
str.x1.length
}
}
// java.lang.ClassCastException: java.lang.Object cannot be cast to java.lang.String// at Test$.main(a.scala:12)// at Test.main(a.scala)
The inferred lub of the list is List[Cell[_ >: Int with String]], which seems fine, except that this existential can't be simplified to "Any" because it leads directly back to the setter for x1. It's hard for me to see how an abstract type declared to be the same as a type parameter can be safely allowed fewer restrictions than the type parameter.
The text was updated successfully, but these errors were encountered:
This is in all versions of scala, it's not a regression or anything.
The inferred lub of the list is List[Cell[_ >: Int with String]], which seems fine, except that this existential can't be simplified to "Any" because it leads directly back to the setter for x1. It's hard for me to see how an abstract type declared to be the same as a type parameter can be safely allowed fewer restrictions than the type parameter.
The text was updated successfully, but these errors were encountered: