NotImplementedError is being thrown in...
dwhjames opened this issue · 2 comments
dwhjames commented
... this example
scala> :paste
// Entering paste mode (ctrl-D to finish)
import scala.async.Async._
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}
import scala.concurrent.ExecutionContext.Implicits.global
def broken() = async {
if (true) {
val n = await(async(1))
if (n < 2) {
throw new RuntimeException("case a")
}
else {
throw new RuntimeException("case b")
}
}
else {
"case c"
}
}
// Exiting paste mode, now interpreting.
import scala.async.Async._
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}
import scala.concurrent.ExecutionContext.Implicits.global
broken: ()scala.concurrent.Future[String]
scala> println(Await.result(broken(), Duration("1 second")))
scala.NotImplementedError: an implementation is missing
at scala.Predef$.$qmark$qmark$qmark(Predef.scala:225)
at stateMachine$macro$2$1.apply(<console>:15)
at stateMachine$macro$2$1.apply(<console>:12)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
at scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Maybe related to #104 and #66?
A workaround for this issue is to provide an explicit return type of Future[String]
to the method.