Skip to content

Instantly share code, notes, and snippets.

@ochafik
Last active December 13, 2015 23:49
Show Gist options
  • Save ochafik/4994400 to your computer and use it in GitHub Desktop.
Save ochafik/4994400 to your computer and use it in GitHub Desktop.
Macro Extensions Plugin Input / Output
@scalaxy.extension[Any]
def quoted(quote: String) = quote + self + quote
// Transformed AST after the `scalaxy-extensions` compilation phase:
import scala.language.experimental.macros
implicit class scalaxy$extensions$quoted$1(self: Any) {
def quoted(quote$Expr$1: String) = macro scalaxy$extensions$quoted$1.quoted
}
object scalaxy$extensions$quoted$1 {
def quoted(c: scala.reflect.macros.Context)
(quote$Expr$1: c.Expr[String]): c.Expr[String] = {
import c.universe._
val Apply(_, List(selfTree$1)) = c.prefix.tree
val self$Expr$1 = c.Expr[Any](selfTree$1)
reify({
val self = self$Expr$1.splice
val quote = quote$Expr$1.splice
quote + self + quote
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment