I want to do this:
trait Renderable {
def render: String
}
trait Parens extends Renderable {
abstract override def render = "(" + super.render + ")"
}
object Foo extends Renderable with Parens {
def render = "Hello"
}
But this does not work because the linearization order puts Parens after Foo (Foo always comes, of course) so Parens can't advise Foo.render.
I end up doing this:
trait FooRender {
def render = "Hello"
}
object Foo extends FooRender with Parens {
}
But sometimes I really don't want to do that because it breaks things up. As far as I can tell, linearization order is the only thing getting in the way, but I don't know a way to change that. What might make this cleaner?