diff options
Diffstat (limited to 'test/files/neg/t8104a/Macros_1.scala')
-rw-r--r-- | test/files/neg/t8104a/Macros_1.scala | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/files/neg/t8104a/Macros_1.scala b/test/files/neg/t8104a/Macros_1.scala new file mode 100644 index 0000000000..688d0694c0 --- /dev/null +++ b/test/files/neg/t8104a/Macros_1.scala @@ -0,0 +1,23 @@ +import scala.reflect.macros.Context + +object Macros { + def impl[T](c: Context)(implicit T: c.WeakTypeTag[T]) = { + import c.universe._ + import Flag._ + import definitions._ + val fields = T.tpe.declarations.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x } + val Repr = appliedType(TupleClass(fields.length).asType.toType, fields.map(_.typeSignature)) + c.Expr(Block( + List(ClassDef( + Modifiers(FINAL), + newTypeName("$anon"), + List(), + Template( + List(AppliedTypeTree(Ident(newTypeName("Generic")), List(TypeTree(T.tpe)))), + emptyValDef, + List( + DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))), + TypeDef(Modifiers(), newTypeName("Repr"), List(), TypeTree(Repr)))))), + Apply(Select(New(Ident(newTypeName("$anon"))), nme.CONSTRUCTOR), List()))) + } +}
\ No newline at end of file |