-
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
Bodies of non-private type aliases must be invariant #6566
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6566?orig=1 |
@milessabin said: object WhatsYourTypeIsMyType {
trait WithMyType[+T] {
type MyType = T
}
class Foo extends WithMyType[Foo] {
var x: MyType = _
def setX() = x = new Foo
}
class Bar extends Foo with WithMyType[Bar] {
def unsound { println("iAmABar") }
setX()
println(x.unsound)
}
def main(args: Array[String]): Unit = new Bar
} |
@paulp said: scala> class In[+T] { type MyType = T }
defined class In
scala> trait Out[T] { val tc: In[T] ; def f(x: tc.MyType): Unit }
defined trait Out
scala> val o1: Out[String] { val tc: In[AnyRef] } = new Out[String] { val tc = new In[String] ; def f(s: String) = () }
o1: Out[String]{val tc: In[AnyRef]} = $anon$1@42929c90
scala> o1.f('hi)
java.lang.ClassCastException: scala.Symbol cannot be cast to java.lang.String
at $anon$1.f(<console>:9)
at .<init>(<console>:11)
at .<clinit>(<console>) I was amazed to see this had gone undiscovered for so long, but then I saw it's a regression... from scala 2.7. Same failure in 2.8 and beyond, but in 2.7 it makes the seemingly correct observation that
|
@retronym said:
|
@retronym said: testing: [...]/files/neg/variances.scala [FAILED]
16,18d15
< variances.scala:89: error: covariant type T occurs in invariant position in type T of type A
< type A = T
< ^
22c19
< 7 errors found
---
> 6 errors found See also: Which introduced the test that now reports two errors rather than one: object TestAlias {
class B[-T]
trait C[+T] {
type A = T
def foo: B[A]
}
} |
@paulp said: |
@odersky said: |
@retronym said: If that goes well, I'll ask Josh to run a community build. We can then choose whether we want to ship the fix on master or 2.10.x. |
@retronym said:
trait ParSeqLike[+T, +Repr <: ParSeq[T], +Sequential <: Seq[T] with SeqLike[T, Sequential]]
extends scala.collection.GenSeqLike[T, Repr]
with ParIterableLike[T, Repr, Sequential] {
self =>
type SuperParIterator = IterableSplitter[T] |
@paulp said: |
@adriaanm said: |
@paulp said:
|
@Blaisorblade said: trait Fun[-S, +T] {type Eval = S => T}
trait Fun0[-S, +T] {
private[this] type Eval = S => T
} I hope this bug is linked in the release notes. |
@Blaisorblade said: I was also trying to refine the spec documenting the current behavior (which is questionable, but I hope it approximates what should be documented to guarantee soundness), and/or comparing what's implemented with the current spec, but I had to give up on that. |
@retronym said: |
@Blaisorblade said: |
@Blaisorblade said: I also added "specification" as component, since scala/scala-dist#131 is still open. (I'm not sure whether to reopen the bug, but I'll better leave the judgment call to you guys). |
Minimization is due to paulp,
Compiles and when run produces a CCE,
The text was updated successfully, but these errors were encountered: