Here's a simplification of the classes I have:
trait RequiredThings {
val requiredThings: Seq[String]
}
class SimpleCalculator with RequiredThings {
val requiredThings = List("a", "b")
}
class ComplicatedCalculator extends SimpleCalculator with RequiredThings {
self: SimpleCalculator =>
override val requiredThings:List[String] = List("c") ::: self.requiredThings
}
In this version, I'm using a self-type annotation, but I'm not completely positive that's the way to go. I think I could probably get it to work by converting requiredThings
to a method throughout, but I'd like to try it as a field.
Final solution:
trait RequiredThings {
def requiredThings: Seq[String]
}
class SimpleCalculator with RequiredThings {
def requiredThings = List("a", "b")
}
class ComplicatedCalculator extends SimpleCalculator with RequiredThings {
override def requiredThings:List[String] = List("c") ::: super.requiredThings
}