Considering:
abstract class Base {
def something() = println("Base")
}
trait TraitA extends Base {
abstract override def something() = { super.something(); println("TraitA"); }
}
class Child extends Base {
override def something() {
println("Child")
}
}
And then:
val x = new Child with TraitA
x.something()
I get:
Child
TraitA
But if I use:
class Child extends Base with TraitA {
override def something() {
println("Child")
}
}
val x = new Child
x.something()
I’d get only:
Child
So what are the differentes of using a trait at construction site or declaration site? Can I have the first behavior (stackable traits) while extending/with’ing the trait in the declaration of the class?
read full post
In your case:
1. super.something() == Child.something()
2. super.something() == Base.something() and Child.something() overrides whole chain
Type of mixin doesn’t matter: