-
Notifications
You must be signed in to change notification settings - Fork 21
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
Unsoundness in overriding methods with higher-order type parameters #2066
Comments
Imported From: https://issues.scala-lang.org/browse/SI-2066?orig=1 |
Vladimir Reshetnikov (nikov) said: class C[T](var y : T)
object A {
val a : AnyRef { def f[T[_]](x : T[int]) : T[Any] } = A
def f[T[+_]](x : T[Int]) : T[Any] = x
} Scala 2.8.0.r18050-b20090618020144 compiler compiles this without scala> val c = new C(1) scala> val c1 = A.a.fC scala> c1.y = "" scala> c.y |
@soc said: Should the compiler reject those examples right at the beginning or can this considered to be fixed? |
@harrah said:
This will throw a !ClassCastException. |
@heathermiller said: Added a test case for this one (pull request) |
@adriaanm said: |
@gkossakowski said: |
@retronym said: https://github.com/retronym/scala/compare/ticket;2066?expand=1 |
@retronym said: |
Try to compile the following code with Scala 2.7.5 final:
It is compiled without any errors. But then you can write:
Result:
So, this way of overriding is unsound.
The text was updated successfully, but these errors were encountered: