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
{{ message }}
Repository navigation
Unsoundness in overriding methods with higher-order type parameters #2066
@heathermiller said: B.f should not be able to implement A.f because the type parameter of T is covariant in B but not in A. This seems like it shouldn't compile.
Activity
scabug commentedon Jun 17, 2009
Imported From: https://issues.scala-lang.org/browse/SI-2066?orig=1
Reporter: Vladimir Reshetnikov (nikov)
See #5517
scabug commentedon Jun 19, 2009
Vladimir Reshetnikov (nikov) said:
Similar issue:
Scala 2.8.0.r18050-b20090618020144 compiler compiles this without
errors. But it seems unsound, as we can write:
scala> val c = new C(1)
c: C[Int] = C@9e7d46
scala> val c1 = A.a.fC
c1: C[Any] = C@9e7d46
scala> c1.y = ""
scala> c.y
java.lang.ClassCastException: java.lang.String cannot be cast to
java.lang.Integer
scabug commentedon Mar 4, 2011
@soc said:
Behavior has changed, both examples compile in 2.9.0.r24324-b20110222020042 and don't throw at runtime.
Should the compiler reject those examples right at the beginning or can this considered to be fixed?
scabug commentedon Apr 7, 2011
@harrah said:
To the original example, add:
val z: Int = p.yThis will throw a !ClassCastException.
scabug commentedon May 7, 2012
@heathermiller said:
B.fshould not be able to implementA.fbecause the type parameter ofTis covariant inBbut not inA. This seems like it shouldn't compile.Added a test case for this one (pull request)
scabug commentedon Feb 3, 2013
@adriaanm said:
fixing this will break existing code -- the rule is only to do that in major versions,
so this will have to wait for 2.11
scabug commentedon Oct 15, 2013
@gkossakowski said:
Unassigning and rescheduling to M7 as previous deadline was missed.
scabug commentedon Nov 22, 2013
@retronym said:
Here's an patch that I'm cobbling together:
https://github.com/retronym/scala/compare/ticket;2066?expand=1
scabug commentedon Nov 22, 2013
@retronym said:
scala/scala#3184