I have a compiler error in scala and I don\'t know what does it refer to:
Assume these declarations:
trait Abstract {
type MyType
}
trait AInner
trait
What is wrong with this?
trait B extends Abstract with A {
override type MyType <: BInner with AInner
}
In any realization of trait B
, MyType
will always be the same type as seen from trait A
, so upper-bounding it by itself does not make any sense.
If in the upper piece of code, it bothers you that you'll have to rewrite trait B
if you change the bound in trait A
, use:
trait A extends Abstract{
type ABound = AInner
type MyType <: AInner
}
trait B extends Abstract with A {
override type MyType <: BInner with ABound
}