我正在关注 akka-in-action 教程,在第 2 章中,有一个类(https://github.com/RayRoestenburg/akka-in-action/blob/master/chapter2/src/main/scala/com/ goticks/RestInterface.scala ):
trait RestApi extends HttpService with ActorLogging { actor: Actor =>
import context.dispatcher
import com.goticks.TicketProtocol._
...
从未使用import context.dispatcher
过,但它是用注释定义的:
/**
* Returns the dispatcher (MessageDispatcher) that is used for this Actor.
* Importing this member will place an implicit ExecutionContext in scope.
*/
implicit def dispatcher: ExecutionContextExecutor
但是,IntelliJ 不断将导入标记为“未使用”并在“优化导入”时将其删除,从而导致错误value pipeTo is not a member of scala.concurrent.Future[Any]
。
有没有办法告诉 IntelliJ 这个导入不是为了“使用”,而只是为了提供一个上下文?
还是应该更新教程以不使用这种“未使用的导入”?