cannot override a concrete member without a third member that's overridden by both
Posted
by huynhjl
on Stack Overflow
See other posts from Stack Overflow
or by huynhjl
Published on 2010-04-08T21:34:46Z
Indexed on
2010/04/08
21:43 UTC
Read the original article
Hit count: 363
What does the following error message mean?
cannot override a concrete member without a third member that's overridden by both (this rule is designed to prevent ``accidental overrides'');
I was trying to do stackable trait modifications. It's a little bit after the fact since I already have a hierarchy in place and I'm trying to modify the behavior without having to rewrite a lot of code.
I have a base class called AbstractProcessor that defines an abstract method sort of like this:
class AbstractProcessor {
def onPush(i:Info): Unit
}
I have a couple existing traits, to implement different onPush behaviors.
trait Pass1 {
def onPush(i:Info): Unit = { ... }
}
trait Pass2 {
def onPush(i:Info): Unit = { ... }
}
So that allows me to use new AbstractProcessor with Pass1
or new AbstractProcessor with Pass2
.
Now I would like to do some processing before and after the onPush call in Pass1 and Pass2 while minimizing code changes to AbstractProcessor and Pass1 and Pass2. I thought of creating a trait that does something like this:
trait Custom extends AbstractProcessor {
abstract override def onPush(i:Info): Unit = {
// do stuff before
super.onPush(i)
// do stuff after
}
And using it with new AbstractProcessor with Pass1 with Custom
and I got that error message.
© Stack Overflow or respective owner