title: Traits and abstract methods override in Scala
body: <p>I have a base abstract class (trait). It has an abstract method <code>foo()</code>. It is extended and implemented by several derived classes. I want to create a trait that can be mixed into the derived classes so that it implements <code>foo()</code> and then calls the derived class's <code>foo()</code>.</p>
  
  <p>Something like:</p>
  
  <pre><code>trait Foo {
    def foo()
  }
  
  trait M extends Foo {
    override def foo() {
      println("M")
      super.foo()
    }
  }
  
  class FooImpl1 extends Foo {
    override def foo() {
      println("Impl")
    }
  }
  
  class FooImpl2 extends FooImpl1 with M 
  </code></pre>
  
  <p>I tried self types and structural types, but I can't get it to work.</p>