In Scala (2.12) when writing a trait I have added a default implementation that can be overridden by some subclasses. Since throughout my entire implementation the state
is required almost everywhere it's implicit such that I don't have to pass it every time it's required.
Considering the following code snippet, the compiler does complain that the implicit parameter state
of SomeTrait.defaultMethod
remains unused and throws an error. Is there any option to suppress this kind of error in that particular scope? I definitely want to keep the unused errors globally.
trait SomeTrait {
def defaultMethod(implicit state: State) : Unit = {
// default implemenation does nothing
}
}
class Subclass extends SomeTrait{
override def deafultMethod(implicit state: State) : Unit = {
state.addInformation()
}
}
Also, I would like to keep the state implicit. In theory, it's possible to add a fake usage to the method but that's not a clean solution.