New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot inference existential type in 2.10 #6679
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6679?orig=1 |
@retronym said: |
@paulp said: Allowing "Type" to be equated to type parameter "A" and then to go on its merry way unsoundly materializes that unknowable type. class ExistentialTypeInference[A](val a: Array[A]) {
type Type = A
def put(x: Type) = a(0) = x
// Even 2.9 knows better than to let this through:
// def put(x: A) = a(0) = x
}
object ExistentialTypeInference {
def main(args: Array[String]) {
val arraySeq = Seq[Array[_]](Array(1, 2), Array("2", "3"))
val t1 = new ExistentialTypeInference(arraySeq.head)
val t2 = new ExistentialTypeInference(arraySeq.last)
t1 put t2.a(0)
}
}
/***
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at scala.runtime.BoxesRunTime.unboxToInt(Unknown Source)
at scala.runtime.ScalaRunTime$.array_update(ScalaRunTime.scala:69)
at ExistentialTypeInference.put(b.scala:3)
at ExistentialTypeInference$.main(b.scala:12)
at ExistentialTypeInference.main(b.scala)
***/ And in 2.10, we fail as we must. % rcscalac b.scala
b.scala:12: error: type mismatch;
found : _$1
required: t1.Type
(which expands to) _$1
t1 put t2.a(0)
^
one error found |
@paulp said: |
This code compiles in 2.9.2, and does not compile in 2.10.x
The text was updated successfully, but these errors were encountered: