diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-03-25 11:25:49 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-03-25 11:25:49 +0100 |
commit | 2af68eec522c97af14b8fad372fc3c0addf7d604 (patch) | |
tree | b2cde03aa63842ddf7875f12e599cb4d4dd23527 /test | |
parent | 876590b2be42a77fc23e5c57fc155d5772265be7 (diff) | |
parent | 3314d76cebc6e27ba4d4ca75cc64fe67fcb90fb6 (diff) | |
download | scala-2af68eec522c97af14b8fad372fc3c0addf7d604.tar.gz scala-2af68eec522c97af14b8fad372fc3c0addf7d604.tar.bz2 scala-2af68eec522c97af14b8fad372fc3c0addf7d604.zip |
Merge pull request #3551 from xeno-by/topic/typecheck-member-def
[nomaster] backports 609047ba37
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/typecheck.check | 0 | ||||
-rw-r--r-- | test/files/run/typecheck/Macros_1.scala | 17 | ||||
-rw-r--r-- | test/files/run/typecheck/Test_2.scala | 15 |
3 files changed, 32 insertions, 0 deletions
diff --git a/test/files/run/typecheck.check b/test/files/run/typecheck.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/typecheck.check diff --git a/test/files/run/typecheck/Macros_1.scala b/test/files/run/typecheck/Macros_1.scala new file mode 100644 index 0000000000..850a611ab1 --- /dev/null +++ b/test/files/run/typecheck/Macros_1.scala @@ -0,0 +1,17 @@ +import scala.reflect.macros.Context +import scala.language.experimental.macros + +object Macros { + def impl(c: Context) = { + import c.universe._ + val classDef = ClassDef( + Modifiers(), newTypeName("C"), List(), + Template( + List(Select(Ident(newTermName("scala")), newTypeName("AnyRef"))), 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(()))))))) + c.typeCheck(classDef) + c.Expr[Any](Literal(Constant(()))) + } + + def foo: Any = macro impl +}
\ No newline at end of file diff --git a/test/files/run/typecheck/Test_2.scala b/test/files/run/typecheck/Test_2.scala new file mode 100644 index 0000000000..0a3279e23e --- /dev/null +++ b/test/files/run/typecheck/Test_2.scala @@ -0,0 +1,15 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + Macros.foo + + val tb = cm.mkToolBox() + val classDef = ClassDef( + Modifiers(), newTypeName("C"), List(), + Template( + List(Select(Ident(newTermName("scala")), newTypeName("AnyRef"))), 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(()))))))) + tb.typeCheck(classDef) +}
\ No newline at end of file |