Scala IDE incorrectly reports an error for the following (correct) code. The error is reported at the
Scala IDE version:
4.2.0.vfinal-2_11-201509251052-b2cb96d
Scala compiler version:
2.11.7
Scala library version:
2.11.7
Eclipse version:
4.4.2.v20150204-1700
scala-async version:
"org.scala-lang.modules" %% "scala-async" % "0.9.5"
await(fut())
call; the error message is: "await must not be used under a nested function.". The error is only shown in the editor (i.e., there is no error indicated in the Problems view or in the Package Explorer). Clicking "Restart Presentation Compiler" doesn't make the error go away.package com.example.test
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
import scala.async.Async.{ async, await }
object Test {
def test(): Future[Int] = async {
val fs: Seq[Future[Int]] = Seq(1, 2, 3).map { i =>
async {
val x = await(fut())
i + x
}
}
await(Future.sequence(fs)).sum
}
def fut(): Future[Int] = Future.successful(5)
}
Scala IDE version:
4.2.0.vfinal-2_11-201509251052-b2cb96d
Scala compiler version:
2.11.7
Scala library version:
2.11.7
Eclipse version:
4.4.2.v20150204-1700
scala-async version:
"org.scala-lang.modules" %% "scala-async" % "0.9.5"
Leave a comment
No file chosen
You have an empty file field. Please select or remove it.
Name | Size |
---|