blob: 8b5c59bde86af91c72a5d52a606e54b6582eebf4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
import scala.reflect.macros.blackbox.Context
object Impls {
def foo[T: c.WeakTypeTag](c: Context)(x: c.Expr[T]) = {
import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(x.tree.toString))))
c.Expr[Unit](body)
}
}
object Macros {
def foo[T](x: T) = macro Impls.foo[T]
}
|