Created
January 4, 2014 14:25
-
-
Save xeno-by/8255893 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.reflect.macros.WhiteboxContext | |
import scala.language.experimental.macros | |
object Macros { | |
def impl(c: WhiteboxContext) = { | |
import c.universe._ | |
val result = c.typecheck(q""" | |
class C[T <: Int] { | |
type Dummy123 = List[T] | |
} | |
() | |
""") | |
result match { | |
case Block(List(ClassDef(_, _, _, Template(_, _, List(_, dummy123: TypeDef)))), _) => | |
println(dummy123.symbol.typeSignature) | |
} | |
q"()" | |
} | |
def foo: Any = macro impl | |
} | |
======= | |
object Test extends App { | |
Macros.foo | |
} | |
======= | |
17:24 ~/Projects/Master/sandbox (master)$ scalac Macros.scala && scalac Test.scala | |
List[T] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment