Inheritance and code reuse in stackable traits
问题 In this simplified experiment, I want to be able to quickly build a class with stackable traits that can report on what traits were used to build it. This reminds me strongly of the decorator pattern, but I'd prefer to have this implemented at compile time rather than at runtime. Working Example with Redundant Code class TraitTest { def report(d: Int) : Unit = { println(s"At depth $d, we've reached the end of our recursion") } } trait Moo extends TraitTest { private def sound = "Moo" override