blob: 8016143a4c40703e4a3554b4c6e93292b4393c08 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import scala.reflect.macros.blackbox.Context
import language.experimental.macros
object MyAttachment
object Macros {
def impl(c: Context) = {
import c.universe._
val ident = Ident(TermName("bar")) updateAttachment MyAttachment
assert(ident.attachments.get[MyAttachment.type].isDefined, ident.attachments)
val typed = c.typecheck(ident)
assert(typed.attachments.get[MyAttachment.type].isDefined, typed.attachments)
c.Expr[Int](typed)
}
def foo = macro impl
}
|