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
variance validation is buggy #7536
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7536?orig=1 |
@paulp said: trait Base[A]
// SHOULD FAIL
trait Neg1[-A] extends Base[A1 forSome { type A1 <: A }]
trait Neg2[-A, A1 <: A] extends Base[A1]
trait Neg3[+A] extends Base[A1 forSome { type A1 >: A }]
trait Neg4[+A, A1 >: A] extends Base[A1]
// SHOULD COMPILE
trait Pos1[-A] extends Base[A1 forSome { type A1 >: A }]
trait Pos2[-A, A1 >: A] extends Base[A1]
trait Pos3[+A] extends Base[A1 forSome { type A1 <: A }]
trait Pos4[+A, A1 <: A] extends Base[A1]
// a.scala:4: error: contravariant type A occurs in invariant position in type [-A]Base[A1 forSome { type A1 <: A }] of trait Neg1
// --- should be "in covariant position"
// a.scala:6: error: covariant type A occurs in invariant position in type [+A]Base[A1 forSome { type A1 >: A }] of trait Neg3
// --- should be "in contravariant position"
// a.scala:10: error: contravariant type A occurs in invariant position in type [-A]Base[A1 forSome { type A1 >: A }] of trait Pos1
// --- should compile
// a.scala:12: error: covariant type A occurs in invariant position in type [+A]Base[A1 forSome { type A1 <: A }] of trait Pos3
// --- should compile |
reopen if still applicable in current Scala |
For the test case above #7536 (comment) in 2.12.4 we have
See https://scastie.scala-lang.org/KH0We1NnSAGqLKUaZ8IrHg. PS why closing and then checking if it's been fixed? |
because it isn't good for the health of the bug tracker to have an overwhelming number of open tickets, many of which are years old and of questionable value. it creates a vicious circle where nobody looks at the tickets because there are too many, and there are too many because nobody looks at them. there are so many we've strongly considered declaring bug bankruptcy and just closing them all. instead, taking a milder approach where we don't just blindly assume every ticket, no matter how old, must be valid. because we need volunteers to confirm which ones are still relevant because reopening is easy when something found to still be relevant. |
I'm going to fix this.
The text was updated successfully, but these errors were encountered: