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 A extends Abstract{
type MyType <: AInner
}
trait BInner {
def bMethod : Int
}
trait B extends Abstract with A{
override type MyType <: BInner with A#MyType
}
What I'm trying to achieve here(in trait B
) is to further restrict the type MyType
declared in Abstract
, so any value of type MyType
must extend all the MyType
s in the mixin tree.
The compiler is giving me this message(as in title):
type MyType is a volatile type; cannot override a type with non-volatile upper bound. I understand, that type volatility is happening here because of type conjuction with A#MyType
, the part of the error: type with non-volatile upper bound probably refers to the type declaration type MyType <: AInner
, where AInner
is not an abstract type thus non-volatile.