I have a trait which is implemented from some other traits. Each of these traits override the behavior of the supertrait and are mixed-in to a class:
trait T {
def name = "t"
}
trait T1 extends T {
abstract override def name = "t1"
}
trait T2 extends T {
abstract override def name = "t2"
}
class C extends T with T1 with T2 {
def printName = super.name
}
Now, in class C
I want to access the behavior not of the last mixed-in trait but the behavior of one of these traits. Is this possible?
It is possible to specialize the super-call to a specific trait:
class C extends T with T1 with T2 {
def printName = super[T1].name
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With