title: How to use stackable trait pattern with Akka actors?
body: <p>I'm trying to implement a Pub/Sub trait to mix into other akka actors using a stackable trait.</p>
  
  <p>Here is what I came up with:</p>
  
  <pre><code>trait PubSubActor extends Actor {
    abstract override def receive = 
      super.receive orElse {
        case Subscribe(topic) =&gt; /* ... */
        case Publish(topic, msg) =&gt; /* ... */
      }
  }
  
  class MyActor extends Actor with PubSubActor {
    override def receive = {
      case SomeMessage(a, b, c) =&gt; /* ... */
    }
  }
  </code></pre>
  
  <p>At which point, the compiler throws back an error: 
  error: overriding method receive in trait MyActor... method receive needs `abstract override' modifiers.</p>
  
  <p>Can you explain to me why this isn't working? How can I fix it so it works?</p>
  
  <p>Thanks!</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The following works:</p>
  
  <pre><code>trait PubSubActor extends Actor {
    abstract override def receive = 
      super.receive orElse {
        case Subscribe(topic) =&gt; /* ... */
        case Publish(topic, msg) =&gt; /* ... */
      }
  }
  
  class MyActor extends Actor {
    override def receive = {
      case SomeMessage(a, b, c) =&gt; /* ... */
    }
  }
  
  class MyActorImpl extends MyActor with PubSubActor
  </code></pre>
  
  <p>But why? Why can I get the behavior I want this way but not the other? Any reasons? I can't seem to figure out the underlying difference between these two samples that makes the difference.</p>