I have an actor that waits for the results of a future. Calling onComplete of the future causes a compiler error:
error: constructor cannot be instantiated to expected type [scalac] found : akka.actor.Status.Success [scalac] required: scala.util.Try[Iterable[Any]] [scalac] case Success(result: List[PCBInstanceStats]) => { [scalac] ^
Actor's receive:
case "pcbStatus" => {
val future = Future.traverse(context.children)(x => {
(x ? "reportStatus")(5 seconds)
})
future.onComplete {
case Success(result: List[PCBInstanceStats]) => {
self ! result
}
}
Not sure how to provide the right type of parameter for this.
[scalac] found : akka.actor.Status.Success
That means the compiler sees your Success
and thinks it's an akka.actor.Status.Success
, when really you mean a scala.util.Success
. You probably have an import somewhere that is importing the akka Success class.
Either remove the import for akka.actor.Status.Success
, or resolve the ambiguity by either fully-qualifying the class, or using an import alias, e.g.
import scala.util.{Success => ScalaSuccess}
future.onComplete {
case ScalaSuccess(result) => ...
// or
case scala.util.Success(result) => ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With