scalascala-macrosscala-maven-plugin

Scala maven builder doesn't understand quasiquotes


I'm building a scala macro project that contains a quasiquote implementation:

    val valDefs = named.map { case (child, name) =>
      q"val $name = play.api.libs.json.Json.writes[$child]"
    }

However when being compiled, maven builder (using incremental compiling mode) throws this error:

[ERROR] /home/peng/git/spookystuff/ispark-macro/src/main/scala/JsMacroImpl.scala:74: value q is not a member of StringContext
[ERROR]           q"val $name = play.api.libs.json.Json.writes[$child]"
[ERROR]           ^

I'm very sure my scala is a rather late version: 2.10.4, why it cannot recognize the new standard?


Solution

  • Quasiquotes have been introduced in 2.11. You would need a compiler plugin for 2.10. See this section at the same address.