This question follows the one in Cake pattern with overriding abstract type don't work with Upper Type Bounds. I want to override the abstract type in trait with <:
. The previous links gives the solution which consists in changing the order of linearization by writting this: Cake with S
in trait S. However, I added a control abstraction named control
in the following code. I want to call the method t
in it.
trait A {
def ping = println("ping")
}
trait Cake {
type T
}
trait S { this: Cake with S =>
type T <: A with S
def t: T
def s = println("test")
// def control(c: =>T): T = c // compile
// def control(c: =>T): T = c.s // does not compile
def control(c: =>T): T = c.t // does not compile
t.ping
t.s
}
But, this code results in a compilation error that I can't explain
found : S.this.T#T
required: S.this.T
def control(c: =>T): T = c.t
^
What is wrong ?