We were talking about possible ways to represent covariant type argument in idiomatic DOT calculus in this thread:
Which contains the following example:
object AsDependentType {
trait Gen {
type Upper
type _CoV = { type T <: Upper }
trait CoV extends P {
private type T <: Upper
val vv: Upper
}
}
trait P {}
object GenY extends Gen {
type Upper = Product
trait P1 extends P with CoV {
val vv: Product
}
}
object GenZ extends Gen {
type Upper = Tuple1[Int]
trait P2 extends GenY.P1 with P with CoV {
val vv: Tuple1[Int]
}
}
implicitly[P with GenZ._CoV <:< P with GenY._CoV]
}
The compiler error for it looks sketchy:
:49:13: error overriding value vv in trait CoV of type Gen.this.Upper;
value vv of type Tuple1[Int] has incompatible type
trait P2 extends GenY.P1 with P with CoV {
val vv: Tuple1[Int]
^
}
Does any one feel the same? If trait CoV is ill-formed, then an error should be thrown at P1.vv. Yet it compiles with no problem. This seems to imply that the compiler is deliberately delegating type bound Upper
to its subtypes.
Let me know your ideal vision about this case