I have a trait with abstract methods and concrete implemented methods, so something like this:
trait MyTrait extends BaseClass {
def myAbstractMethod: MyReturnType
def myConcreteMethod = { /*implementation*/ }
}
Now I mixin the trait:
class MyClass extends BaseClass with MyTrait {
}
The BaseClass does not implement the abstract method. I expected the scala compiler to enforce that the abstract method must be implemented (just like a Java interface) when I mix in the trait. But there is no compiler error.
My particular case is more complicated. I was not able to test what happens at runtime, yet.
- Why doesn't the scala compiler enforce the implementation of the abstract method?
- Can I make the scala compiler enforce the implementation of the abstract method?
- Must I add abstract or override somewhere?
- What happens at runtime when I try to create and use instances of MyClass?