I have a method in my trait
def controller: AnyRef
but my concrete class was not implementing that method and it was still compiling. The compiler doesn't let me add abstract to that method either. How can I create a method in a trait that forces it's implementer to implement it?
thanks, Dean
The compiler enforces that concrete classes implement all the abstracts methods they inherit from superclasses and traits.
If your class was compiling it meant it wasn't concrete, i.e. it was a
traitor anabstract class, and you can't force neither to implement the abstract method.Of course, as soon as you try to obtain a concrete instance the compiler will raise an error as the method is not implemented.
Practical example in the REPL