blob: aa76a410eaab2c69754bbd9732353718d2e500fc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import scala.reflect.runtime.universe._
import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo_targs[T, U: c.WeakTypeTag](c: Ctx = null)(x: c.Expr[Int] = null) = {
import c.{prefix => prefix}
import c.universe._
val U = implicitly[c.WeakTypeTag[U]]
c.Expr[Unit](q"""
println("invoking foo_targs...")
println("type of prefix is: " + ${prefix.staticType.toString})
println("type of prefix tree is: " + ${prefix.tree.tpe.toString})
println("U is: " + ${U.tpe.toString})
""")
}
}
class Macros[T] {
def foo_targs[U](x: Int) = macro Impls.foo_targs[T, U]
}
|