blob: e135bd807b1103898609e3ce36b1eb3db178169a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
|
import scala.reflect.macros.whitebox.Context
object Macros {
def impl[T](c: Context)(implicit T: c.WeakTypeTag[T]) = {
import c.universe._
import definitions._
val fields = T.tpe.decls.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x }
val Repr = appliedType(TupleClass(fields.length).asType.toType, fields.map(_.info))
q"new Generic[$T]{ type Repr = $Repr }"
}
}
|