summaryrefslogtreecommitdiff
path: root/test/files/run/typecheck
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2014-02-12 12:11:40 +0100
committerEugene Burmako <xeno.by@gmail.com>2014-02-12 15:21:15 +0100
commit609047ba372ceaf06916d3361954bc949a6906ee (patch)
tree93eceb1b342ea114b4923ef258a9409a054197a9 /test/files/run/typecheck
parent98320a6d5947f26e7252b025cf56a0763b39cd07 (diff)
downloadscala-609047ba372ceaf06916d3361954bc949a6906ee.tar.gz
scala-609047ba372ceaf06916d3361954bc949a6906ee.tar.bz2
scala-609047ba372ceaf06916d3361954bc949a6906ee.zip
typecheck(q"class C") no longer crashes
MemberDefs alone can't be typechecked as is, because namer only names contents of PackageDefs, Templates and Blocks. And, if not named, a tree can't be typed. This commit solves this problem by wrapping typecheckees in a trivial block and then unwrapping the result when it returns back from the typechecker.
Diffstat (limited to 'test/files/run/typecheck')
-rw-r--r--test/files/run/typecheck/Macros_1.scala12
-rw-r--r--test/files/run/typecheck/Test_2.scala10
2 files changed, 22 insertions, 0 deletions
diff --git a/test/files/run/typecheck/Macros_1.scala b/test/files/run/typecheck/Macros_1.scala
new file mode 100644
index 0000000000..ee1c8da763
--- /dev/null
+++ b/test/files/run/typecheck/Macros_1.scala
@@ -0,0 +1,12 @@
+import scala.reflect.macros.whitebox._
+import scala.language.experimental.macros
+
+object Macros {
+ def impl(c: Context) = {
+ import c.universe._
+ c.typecheck(q"class C")
+ q"()"
+ }
+
+ 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..01bf5198cc
--- /dev/null
+++ b/test/files/run/typecheck/Test_2.scala
@@ -0,0 +1,10 @@
+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()
+ tb.typecheck(q"class C")
+} \ No newline at end of file