Last but not least there is a little bit of convenience magic built-in, which detects if the runtime class of the statically given actor subtype extends the RequiresMessageQueue trait via the Stash trait (this is a complicated way of saying that new Act with Stash would not work because its runtime erased type is just an anonymous subtype of Act). The purpose is to automatically use the appropriate deque-based mailbox type required by Stash. If you want to use this magic, simply extend ActWithStash:
val a = actor(new ActWithStash {
become {
case 1 ⇒ stash()
case 2 ⇒
testActor ! 2; unstashAll(); becomeStacked {
case 1 ⇒ testActor ! 1; unbecome()
}
}
})