summaryrefslogtreecommitdiff
path: root/test/files/run/t7617b
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-06-27 17:10:47 +0200
committerEugene Burmako <xeno.by@gmail.com>2013-07-09 15:09:38 +0200
commite72ae708ed39ad006ef7dbbb85e116a8e6704663 (patch)
treeefe31be83f23f421a00b95c1c39e681ae2a3715b /test/files/run/t7617b
parent55decf733eb361c235ef1bd9039e5c6226202a96 (diff)
downloadscala-e72ae708ed39ad006ef7dbbb85e116a8e6704663.tar.gz
scala-e72ae708ed39ad006ef7dbbb85e116a8e6704663.tar.bz2
scala-e72ae708ed39ad006ef7dbbb85e116a8e6704663.zip
SI-7617 typedAssign no longer expands lhs
This makes sure that setter and updateDynamic macros work as intended rather than in some cases expanding incorrectly or prematurely. Setter invocations are desugared from assignments of values to getters. If a typecheck of an assignment's lhs yields an invocation of a getter, then the assignment is rewritten into an invocation of a setter. However if a getter is a macro, then it just expands, destroying the prerequisite for desugaring. Therefore we need to disable expansion for the typecheck of an lhs. Similar thing happens to updateDynamic that first desugars a getter invocation into q"$target.updateDynamic($fieldName)" and then expects typedAssign to rewrite the corresponding Assign node into an additional application of a partially applied updateDynamic to a rhs. Here we also need to disable the typecheck of an lhs, because macros cannot be partially applied.
Diffstat (limited to 'test/files/run/t7617b')
-rw-r--r--test/files/run/t7617b/Macros_1.scala8
-rw-r--r--test/files/run/t7617b/Test_2.scala11
2 files changed, 19 insertions, 0 deletions
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