2
votes

The following is my code, where I get the exception in the question title

ActorRef and the ask function here are both Akka, but I have no idea what the above exception means. Even a search on Google doesn't produce much on NotInferedB....can someone shed some light?

def exchangeRateLookup(exchangeRateActor: ActorRef): (Option) => Future[Any] = {
        (iv: Option) => iv map (iv => ask(exchangeRateActor, iv.asInstanceOf[IV].getCurrency.getIsoCurrCode)).getOrElse(Future.successful())      
      }

Edit

I have now corrected my code to add the applicable typing but now I get a "missing parameter type" error. This is my latest code:

(iv: Option[IV]) => iv map (i => ask(exchangeRateActor, i.getCurrency.getIsoCurrCode)).getOrElse(Future.successful[Null](null))

Any further ideas?

2

2 Answers

1
votes

Future.successful[T](result: T): Future[T] returns a Future that was already completed. If you call it without parameters, it should fail compilation. I suggest you fix that first. Also, iv is declared to be an Option, without any type parameter (Option[T]). Then, you cast it to IV, so you can extract the currency from it. Unless IV is a type declared somewhere else in your class, and which is guaranteed to have a "getCurrency()" method, I do not see how this can work. Let's fix these things first, and see what happens.

1
votes

To correct the other answer, 2.11 shows that the Unit value is inserted in the parens here:

scala> :se +deprecation

scala> Future.successful()
<console>:51: warning: Adaptation of argument list by inserting () has been deprecated: this is unlikely to be what you want.
        signature: Future.successful[T](result: T): scala.concurrent.Future[T]
  given arguments: <none>
 after adaptation: Future.successful((): Unit)
              Future.successful()
                               ^
res1: scala.concurrent.Future[Unit] = scala.concurrent.impl.Promise$KeptPromise@60dac573

(On 2.10, try -Xlint or -Ywarn-adapted-args etc.)

Option.getOrElse can return a wider type if the type of the else part is wrong.

See the puzzler.

But ask is a Future[Any].