blob: 3f67ac17b2d69bd68633c477c7129fb2af1f19fb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import language.experimental.macros
object Macro {
import reflect.macros.blackbox.Context
def impl(c: Context)(): c.Tree = {
import c.universe._
val tree = q"""class C; new C"""
val tree1 = c.typecheck(tree)
val tpe = tree1.tpe
val tree2 = c.typecheck(c.untypecheck(tree1))
q"""$tree2.asInstanceOf[$tpe]"""
}
def apply(): Any = macro impl
}
|