Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

async in scala : macro has not been expanded

I am not sure as to why this simple code would lead to an error:

object Main {

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

The 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
like image 548
nicolas Avatar asked Dec 25 '22 17:12

nicolas


1 Answers

This seems to be a known problem (which has been fixed but probably won’t be available before Scala 2.11). As it’s got to do with the implicit, you can try to work around it by making the implicit explicit:

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

(As this question is related to the Coursera assignment, I know that you have defined an implicit class FutureCompanionOps[T] which takes a type parameter and which appears to be the problem here.)

like image 105
Debilski Avatar answered Dec 29 '22 07:12

Debilski