Closed
Description
Clearly there is a bug here, but I don't know whether the bug is that both should compile or that neither should. If protected[this] is supposed to turn off variance checks like private[this] does, I don't see it in the spec. So I'm supposing neither should compile.
The following fails with a variance error:
trait C1[+A, +CC[X]] {
protected[this] def f: A => CC[A] = sys.error("")
}
trait C2[+A, +CC[X]] extends C1[A, CC] {
override protected[this] def f = super.f
}
// bug.scala:6: error: covariant type A occurs in contravariant position in type => (A) => CC[A] of method super$$f
// override protected[this] def f = super.f
// ^
// one error found
If we change C2 to a class, it compiles.
trait C1[+A, +CC[X]] {
protected[this] def f: A => CC[A] = sys.error("")
}
class C2[+A, +CC[X]] extends C1[A, CC] {
override protected[this] def f = super.f
}
Metadata
Metadata
Assignees
Labels
No labels