Async in scala: macro has not been extended

I am not sure why this simple code will result in an error:

object Main {

  def main(args: Array[String]) {
    val userInterrupted: Future[String] = async {
      var inp =   await { Future.userInput("")}
      "You entered... " + inp
    }
  }
}

Error message:

[error] /Users/reactive programming coursera/nodescala/src/main/scala/nodescala/Main.scala:18: macro has not been expanded
[error]     val userInterrupted: Future[String] = async {
[error]                                           ^
[error] one error found
[error] (assignment/compile:compile) Compilation failed
+4
source share
1 answer

This seems to be a known issue (which is fixed, but probably won't be available until Scala 2.11). Since this is due to implicit, you can try to get around this by making an implicit explicit:

var inp = await { FutureCompanionOps(Future).userInput("") }

(Since this question is related to the purpose of Coursera , I know that you have defined implicit class FutureCompanionOps[T]which accepts the type parameter and which seems to be the problem here.)

+10
source

All Articles