summaryrefslogtreecommitdiff
path: root/test/files/neg/macro-quasiquotes
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-07-10 14:52:45 +0200
committerEugene Burmako <xeno.by@gmail.com>2013-07-10 17:50:47 +0200
commit114d52b1f8be07a95125397879b170e8496c0c2e (patch)
treeaf44d71e1ee4fd9d547150af7018f77ce71f960d /test/files/neg/macro-quasiquotes
parentaada28f92745b21b1fbed81d8c956d60b5d556b9 (diff)
downloadscala-114d52b1f8be07a95125397879b170e8496c0c2e.tar.gz
scala-114d52b1f8be07a95125397879b170e8496c0c2e.tar.bz2
scala-114d52b1f8be07a95125397879b170e8496c0c2e.zip
macro impls can now return subtypes of c.Tree
10229316db allowed macro impls to take and return values of type c.Tree in addition to the usual c.Expr. However it didn't take into account that it is often useful to return subtypes of trees (e.g. with quasiquotes that expand into expressions typed as precisely as possible). This patch fixes that oversight.
Diffstat (limited to 'test/files/neg/macro-quasiquotes')
-rw-r--r--test/files/neg/macro-quasiquotes/Macros_1.scala15
-rw-r--r--test/files/neg/macro-quasiquotes/Test_2.scala5
2 files changed, 20 insertions, 0 deletions
diff --git a/test/files/neg/macro-quasiquotes/Macros_1.scala b/test/files/neg/macro-quasiquotes/Macros_1.scala
new file mode 100644
index 0000000000..17c1034720
--- /dev/null
+++ b/test/files/neg/macro-quasiquotes/Macros_1.scala
@@ -0,0 +1,15 @@
+import language.experimental.macros
+import scala.reflect.macros.Macro
+
+trait Impls extends Macro {
+ import c.universe._
+ def impl1(x: Expr[Int]) = q"println(x)"
+ def impl2(x: Tree) = q"println(x)"
+ def impl3(x: Block) = q"println(x)"
+}
+
+object Macros {
+ def m1(x: Int) = macro Impls.impl1
+ def m2(x: Int) = macro Impls.impl2
+ def m3(x: Int) = macro Impls.impl3
+} \ No newline at end of file
diff --git a/test/files/neg/macro-quasiquotes/Test_2.scala b/test/files/neg/macro-quasiquotes/Test_2.scala
new file mode 100644
index 0000000000..c7b8948d79
--- /dev/null
+++ b/test/files/neg/macro-quasiquotes/Test_2.scala
@@ -0,0 +1,5 @@
+object Test extends App {
+ Macros.m1
+ Macros.m2
+ Macros.m3
+}