我有一个简单的PartialFunction
type ChildMatch = PartialFunction[Option[ActorRef], Unit]
def idMatch(msg: AnyRef, fail: AnyRef)(implicit ctx: ActorContext): ChildMatch = {
case Some(ref) => ref forward msg
case _ => ctx.sender() ! fail
}但是当我尝试使用这个编译器时,我想要这样的声明:
...
implicit val ctx: ActorContext
val id: String = msg.id
idMatch(msg, fail)(ctx)(ctx.child(id))如您所见,它希望ctx作为第二个参数,而不是隐式的。
如何将我的idMatch函数更改为这样使用它:
...
implicit val ctx: ActorContext
val id: String = msg.id
idMatch(msg, fail)(ctx.child(id))发布于 2018-11-27 13:15:28
编译器总是假定第二个参数列表代表隐式参数列表。您必须以某种方式拆分这两个函数的调用。以下是一些可能性:
idMatch(msg, fail).apply(ctx.child(id))
val matcher = idMatch(msg, fail)
matcher(ctx.child(id))
// Provides the implicit explicitly from the implicit scope
idMatch(msg, fail)(implicitly)(ctx.child(id))https://stackoverflow.com/questions/53500312
复制相似问题