Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upUnsoundness in overriding methods with higher-order type parameters #2066
Comments
This comment has been minimized.
This comment has been minimized.
Imported From: https://issues.scala-lang.org/browse/SI-2066?orig=1 |
This comment has been minimized.
This comment has been minimized.
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 |
This comment has been minimized.
This comment has been minimized.
@soc said: Should the compiler reject those examples right at the beginning or can this considered to be fixed? |
This comment has been minimized.
This comment has been minimized.
@harrah said:
This will throw a !ClassCastException. |
This comment has been minimized.
This comment has been minimized.
@heathermiller said: Added a test case for this one (pull request) |
This comment has been minimized.
This comment has been minimized.
@adriaanm said: |
This comment has been minimized.
This comment has been minimized.
@gkossakowski said: |
This comment has been minimized.
This comment has been minimized.
@retronym said: https://github.com/retronym/scala/compare/ticket;2066?expand=1 |
This comment has been minimized.
This comment has been minimized.
@retronym said: |
scabug commentedJun 17, 2009
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.