I have a trait I (intermediary), a class M (mixer) mixing in the trait and a trait S (specific).
class M extends Something with S {
def baz() = foo()
}
trait I {
def foo(): { ...; bar(); ... }
def bar()
}
trait S extends I {
def bar() = 42
}
I serves as an intermediate layer between M and S, providing a common interface.
I have an implemented method foo in I that calls a method bar (not implemented in I but defined there). What I would like to achieve is that all traits extending I must implement bar, so that this would throw a compile time error because bar is not implemented:
trait Z extends I
Is this possible in Scala?
P.S.: I am aware of the answer of Force Scala trait to implement a certain method but I do not want that kind of explicit coupling.
traitto implement something like that.