Here's a smallest example
package org.example
import akka.actor._
import akka.pattern.ask
import akka.util.duration._
import akka.util.Timeout
class Counter extends Actor {
def receive = {
case _ => sender ! "hi"
}
}
object AkkaProjectInScala extends App {
val system = ActorSystem("AkkaProjectInScala")
val counter = system.actorOf(Props[Counter])
// this will raise NullPointerException
(counter ? "i just came to say hello") onSuccess {
case x => println("He said " + x)
}
implicit val timeout = Timeout(5 seconds)
system.shutdown()
}
This seems weird because the implicits raise compile error when I try something like this in the console
scala> def magic(a: Int)(implicit b: Int) = a + b
magic: (a: Int)(implicit b: Int)Int
scala> magic(3)
<console>:9: error: could not find implicit value for parameter b: Int
magic(3)
Is there some other magic which happens when using Akka which prevents the compiler from detecting this at compile time?