A PartialFunctionis a trait that you can implement. You should not use syntax case.
Unfortunately, it does not have a convenient method for compiling as you describe. The closest method andThen, but the argument you pass in should be a regular function, which can lead to matching errors when the argument is not processed in the actual receive function. So you are stuck in writing this long way.
class MessageInterceptor(receiver: Receive) extends Receive {
def apply(msg: Any) = {
/* do whatever things here */
receiver.apply(msg)
}
def isDefinedAt(msg: Any) = receiver.isDefinedAt(msg)
}
val process = new MessageInterceptor(receive)