1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
trait Periods { self: Context => def atPhase(id: Int): Unit = println(s"atPhase: $id") } class Phase(val id: Int) trait Phases { self: Context => def atPhase(phase: Phase): Unit = self.atPhase(phase.id) } trait Context extends Phases with Periods object Test extends Context { def main(args: Array[String]) = atPhase(new Phase(2)) }