summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2013-07-12 11:57:39 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2013-07-12 11:57:39 -0700
commite9fbdb22c94cd3ab7c4d297c6e9c61fc86263b4c (patch)
tree108c5081b02923a2f8889afc1f02673f09ef64dc /test/files/run
parent69901bf25d5a83d6b7bc002b76e69a1a8d38546b (diff)
parente72ae708ed39ad006ef7dbbb85e116a8e6704663 (diff)
downloadscala-e9fbdb22c94cd3ab7c4d297c6e9c61fc86263b4c.tar.gz
scala-e9fbdb22c94cd3ab7c4d297c6e9c61fc86263b4c.tar.bz2
scala-e9fbdb22c94cd3ab7c4d297c6e9c61fc86263b4c.zip
Merge pull request #2689 from scalamacros/ticket/7617
SI-7617 typedAssign no longer expands lhs
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/t7617a.check2
-rw-r--r--test/files/run/t7617a/Macros_1.scala22
-rw-r--r--test/files/run/t7617a/Test_2.scala5
-rw-r--r--test/files/run/t7617b.check1
-rw-r--r--test/files/run/t7617b/Macros_1.scala8
-rw-r--r--test/files/run/t7617b/Test_2.scala11
6 files changed, 49 insertions, 0 deletions
diff --git a/test/files/run/t7617a.check b/test/files/run/t7617a.check
new file mode 100644
index 0000000000..94954abda4
--- /dev/null
+++ b/test/files/run/t7617a.check
@@ -0,0 +1,2 @@
+hello
+world
diff --git a/test/files/run/t7617a/Macros_1.scala b/test/files/run/t7617a/Macros_1.scala
new file mode 100644
index 0000000000..f9772c83c0
--- /dev/null
+++ b/test/files/run/t7617a/Macros_1.scala
@@ -0,0 +1,22 @@
+import scala.reflect.macros.Context
+import language.experimental.macros
+
+object Macros {
+ def getValueImpl[T](c: Context): c.Expr[T] = {
+ import c.universe._
+ c.Expr[T](Apply(Select(c.prefix.tree, newTermName("getVal")), Nil))
+ }
+ def setValueImpl[T](c: Context)(value: c.Expr[T]): c.Expr[Unit] = {
+ import c.universe._
+ c.Expr[Unit](Apply(Select(c.prefix.tree, newTermName("setVal")), List(value.tree)))
+ }
+}
+
+object Module {
+ private var _val: String = "hello"
+ def setVal(value: String): Unit = this._val = value
+ def getVal(): String = this._val
+
+ def value: String = macro Macros.getValueImpl[String]
+ def value_=(value: String): Unit = macro Macros.setValueImpl[String]
+}
diff --git a/test/files/run/t7617a/Test_2.scala b/test/files/run/t7617a/Test_2.scala
new file mode 100644
index 0000000000..da6e34e09d
--- /dev/null
+++ b/test/files/run/t7617a/Test_2.scala
@@ -0,0 +1,5 @@
+object Test extends App {
+ println(Module.value)
+ Module.value = "world"
+ println(Module.value)
+} \ No newline at end of file
diff --git a/test/files/run/t7617b.check b/test/files/run/t7617b.check
new file mode 100644
index 0000000000..81ec7e8b74
--- /dev/null
+++ b/test/files/run/t7617b.check
@@ -0,0 +1 @@
+foo = 2
diff --git a/test/files/run/t7617b/Macros_1.scala b/test/files/run/t7617b/Macros_1.scala
new file mode 100644
index 0000000000..bc919935c9
--- /dev/null
+++ b/test/files/run/t7617b/Macros_1.scala
@@ -0,0 +1,8 @@
+import scala.reflect.macros.Context
+
+object Macros {
+ def impl(c: Context)(name: c.Expr[String])(value: c.Expr[Any]) = {
+ import c.universe._
+ reify(println(s"${name.splice} = ${value.splice}"))
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t7617b/Test_2.scala b/test/files/run/t7617b/Test_2.scala
new file mode 100644
index 0000000000..e27f650e80
--- /dev/null
+++ b/test/files/run/t7617b/Test_2.scala
@@ -0,0 +1,11 @@
+import scala.language.dynamics
+import language.experimental.macros
+
+class C extends Dynamic {
+ def updateDynamic(name: String)(value: Any) = macro Macros.impl
+}
+
+object Test extends App {
+ val c = new C
+ c.foo = 2
+} \ No newline at end of file