object Test {
trait Foo
trait Bar {
def someMethod(): Unit
val someValue: String
}
trait Runner {
protected type A <: Foo
def run(a: A): Unit
}
trait Runner2 {
this: Runner =>
protected type A <: Foo with Bar
def run(a: A): Unit = a.someMethod()
}
}
In the above example, if Runner2 is not self-typed as Runner, the code compiles, but if it is, it does not:
Error:(42, 29) value someMethod is not a member of Runner2.this.A
def run(a: A): Unit = a.someMethod()
I understand this is because the self-typing causes Runner.A to "take precedence" over Runner2's override, but - why?
If I don't use the self-typing, other issues arise with concrete implementations of Runner2, since such implementations extend Runner and mix-in Runner2.
What's the best way to handle such relationships?