Created
December 16, 2013 16:18
-
-
Save xeno-by/7989709 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.reflect.macros.Context | |
import scala.language.experimental.macros | |
import scala.reflect.api.Liftable | |
object liftableMacro { | |
implicit def liftableCaseClass[T]: Liftable[T] = macro impl | |
def impl(c: Context): c.Tree = { | |
import c.universe._ | |
val spliced: List[Tree] = List(q"???") | |
val s = "" | |
q"Apply(Ident(TermName($s)), List(..$spliced))" | |
} | |
} | |
> compile | |
[info] Compiling 1 Scala source to /Users/xeno_by/Projects/macros-playground/macros/target/scala-2.11.0-M7/classes... | |
[[syntax trees at end of typer]] // Macros.scala | |
package <empty> { | |
import scala.reflect.macros.Context; | |
import scala.language.experimental.macros; | |
import scala.reflect.api.Liftable; | |
object liftableMacro extends scala.AnyRef { | |
def <init>(): liftableMacro.type = { | |
liftableMacro.super.<init>(); | |
() | |
}; | |
@scala.reflect.macros.internal.macroImpl(`macro`("versionFormat" = 6.0, "isBundle" = false, "isBlackbox" = false, "className" = "liftableMacro$", "methodName" = "impl", "signature" = List(List(-1)))) implicit <macro> def liftableCaseClass[T]: scala.reflect.api.Liftable[T] = liftableMacro.this.impl; | |
def impl(c: reflect.macros.Context): c.Tree = { | |
import c.universe._; | |
val spliced: List[c.universe.Tree] = immutable.this.List.apply[c.universe.Ident](c.universe.Ident.apply(c.universe.TermName.apply("$qmark$qmark$qmark"))); | |
val s: String = ""; | |
c.universe.build.SyntacticApply.apply(c.universe.Ident.apply(c.universe.TermName.apply("Apply")), scala.collection.immutable.List.apply[c.universe.Tree](c.universe.build.SyntacticApply.apply(c.universe.Ident.apply(c.universe.TermName.apply("Ident")), scala.collection.immutable.List.apply[c.universe.Tree](c.universe.build.SyntacticApply.apply(c.universe.Ident.apply(c.universe.TermName.apply("TermName")), scala.collection.immutable.List.apply[c.universe.Tree](api.this.Liftable.liftString.apply(c.universe, s).asInstanceOf[c.universe.Tree])))), c.universe.build.SyntacticApply.apply(c.universe.Ident.apply(c.universe.TermName.apply("List")), liftableMacro.this.liftableCaseClass(c.universe, spliced).asInstanceOf[c.universe.Tree]))) | |
} | |
} | |
} | |
[error] /Users/xeno_by/Projects/macros-playground/macros/src/main/scala/Macros.scala:11: erroneous or inaccessible type | |
[error] q"Apply(Ident(TermName($s)), List(..$spliced))" | |
[error] ^ | |
[error] one error found | |
[error] (macros/compile:compile) Compilation failed | |
[error] Total time: 0 s, completed Dec 16, 2013 5:14:24 PM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment