aboutsummaryrefslogtreecommitdiff
path: root/tests/untried/neg/t5903e
diff options
context:
space:
mode:
Diffstat (limited to 'tests/untried/neg/t5903e')
-rw-r--r--tests/untried/neg/t5903e/Macros_1.scala25
-rw-r--r--tests/untried/neg/t5903e/Test_2.scala6
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/untried/neg/t5903e/Macros_1.scala b/tests/untried/neg/t5903e/Macros_1.scala
new file mode 100644
index 000000000..a64ff7e0b
--- /dev/null
+++ b/tests/untried/neg/t5903e/Macros_1.scala
@@ -0,0 +1,25 @@
+import scala.reflect.macros.whitebox.Context
+import language.experimental.macros
+
+object Interpolation {
+ implicit class TestInterpolation(c: StringContext) {
+ object t {
+ def unapply(x: Int): Any = macro Macros.unapplyImpl
+ }
+ }
+}
+
+object Macros {
+ def unapplyImpl(c: Context)(x: c.Tree) = {
+ import c.universe._
+ q"""
+ new {
+ class Match(x: Int) extends AnyVal {
+ def isEmpty = false
+ def get = x
+ }
+ def unapply(x: Int) = new Match(x)
+ }.unapply($x)
+ """
+ }
+}
diff --git a/tests/untried/neg/t5903e/Test_2.scala b/tests/untried/neg/t5903e/Test_2.scala
new file mode 100644
index 000000000..d69d47243
--- /dev/null
+++ b/tests/untried/neg/t5903e/Test_2.scala
@@ -0,0 +1,6 @@
+class C {
+ import Interpolation._
+ 42 match {
+ case t"$x" => println(x)
+ }
+}