For the code:
Macros.manipulate(<foo></foo>)
If I define the manipulate as:
object Macros {
def manipulate(elem: Elem): Elem = macro Bundle.impl
}
class Bundle(val c: Context) extends MacroLiftables {
import c.universe._
def impl(elem: Tree): Tree = {
val q"<foo></foo>" = elem
q"$result"
}
}
It can never match:
[error] /Users/twer/workspace/xml-example/core/src/main/scala/Test.scala:17: exception during macro expansion:
[error] scala.MatchError: {
[error] {
[error] new scala.xml.Elem(null, "foo", scala.xml.Null, scala.this.xml.TopScope, false)
[error] }
[error] } (of class scala.reflect.internal.Trees$Block)
[error] at Bundle.impl(Macros.scala:17)
[error] println(Macros.manipulate(<foo></foo>))
[error] ^
[error] one error found
[error] (core/compile:compile) Compilation failed
[error] Total time: 2 s, completed Mar 7, 2015 8:40:54 PM
>
For the code:
If I define the
manipulateas:It can never match: