summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-09-26 15:05:36 +0200
committerEugene Burmako <xeno.by@gmail.com>2013-09-26 16:39:19 +0200
commit7122560063b4cbe1e8012decbc842bf610e55863 (patch)
treeb73e4804208e752248e6d60bfcbf96ece52a3987 /test/files
parentbda48577d022811be58ce2b7f9e46890543ad45b (diff)
downloadscala-7122560063b4cbe1e8012decbc842bf610e55863.tar.gz
scala-7122560063b4cbe1e8012decbc842bf610e55863.tar.bz2
scala-7122560063b4cbe1e8012decbc842bf610e55863.zip
transformers no longer ignore UnApply.fun
Second time's the charm. I remember trying to do exactly the same somewhen around 2.10.0-M4, but then some continuations tests were failing. Luckily, today everything went smoothly. Please note that this fix changes the way that SI-5465 manifests itself. Previously it produced type errors, now it simply crashes the compiler. Therefore I had to attach the try/catch FatalError clause to invocations of toolbox methods, so that compiler crashes get caught and translated to ToolBoxErrors. Also fixes SI-7871, and that clears the way for implementing quasiquotes with conventional macros rather than relying on a special case in typer.
Diffstat (limited to 'test/files')
-rw-r--r--test/files/run/t7871.check1
-rw-r--r--test/files/run/t7871/Macros_1.scala27
-rw-r--r--test/files/run/t7871/Test_2.scala6
3 files changed, 34 insertions, 0 deletions
diff --git a/test/files/run/t7871.check b/test/files/run/t7871.check
new file mode 100644
index 0000000000..ce6efd812d
--- /dev/null
+++ b/test/files/run/t7871.check
@@ -0,0 +1 @@
+(SomeTree,SomeTree)
diff --git a/test/files/run/t7871/Macros_1.scala b/test/files/run/t7871/Macros_1.scala
new file mode 100644
index 0000000000..778068deb3
--- /dev/null
+++ b/test/files/run/t7871/Macros_1.scala
@@ -0,0 +1,27 @@
+import scala.reflect.macros.Context
+import language.experimental.macros
+
+trait Tree
+case object SomeTree extends Tree
+
+object NewQuasiquotes {
+ implicit class QuasiquoteInterpolation(c: StringContext) {
+ object nq {
+ def unapply(t: Tree) = macro QuasiquoteMacros.unapplyImpl
+ }
+ }
+}
+
+object QuasiquoteMacros {
+ def unapplyImpl(c: Context)(t: c.Tree) = {
+ import c.universe._
+ q"""
+ new {
+ def unapply(t: Tree) = t match {
+ case SomeTree => Some((SomeTree, SomeTree))
+ case _ => None
+ }
+ }.unapply($t)
+ """
+ }
+}
diff --git a/test/files/run/t7871/Test_2.scala b/test/files/run/t7871/Test_2.scala
new file mode 100644
index 0000000000..3a0b68b568
--- /dev/null
+++ b/test/files/run/t7871/Test_2.scala
@@ -0,0 +1,6 @@
+object Test extends App {
+ import NewQuasiquotes._
+ SomeTree match {
+ case nq"$x + $y" => println((x, y))
+ }
+}