How to have multiple traits of same base trait implement the same method
问题 I have a scenario with multiple traits inheriting from a fixed base trait. The base trait has an abstract method that each needs to implement. The class using these traits also needs to implement this method: trait A { def f: Any } trait B1 extends A { val i: Int override def f: Any = println("B1: " + i) } trait B2 extends A { val j: Int override def f: Any = println("B2: " + j) } class C extends A with B1 with B2 { val i = 1 val j = 2 override def f: Any = { super.f println("C::f") } } Then