Skip to content

Instantly share code, notes, and snippets.

@xeno-by
Created January 4, 2014 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xeno-by/8255893 to your computer and use it in GitHub Desktop.
Save xeno-by/8255893 to your computer and use it in GitHub Desktop.
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