summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Schaefer <mail@antoras.de>2013-11-24 00:07:31 +0100
committerJason Zaugg <jzaugg@gmail.com>2013-11-26 19:02:54 +0100
commit3629b645cc2b1403c51925dd9c696a57008c0ce2 (patch)
treea1943705b83d870e96cd4270707e0be3c03f5f5b
parent696545d53f89d8a764273dacca5c6d3043911722 (diff)
downloadscala-3629b645cc2b1403c51925dd9c696a57008c0ce2.tar.gz
scala-3629b645cc2b1403c51925dd9c696a57008c0ce2.tar.bz2
scala-3629b645cc2b1403c51925dd9c696a57008c0ce2.zip
SI-8005 Fixes NoPositon error for updateDynamic calls
Previously there occurred a NoPosition error when one asks for position information in the AST because no positions were set to the trees created during the transformation for updateDynamic calls. This commit applies range positions to the trees in order to being able to highlight them inside of the scala-ide.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala4
-rw-r--r--test/files/run/dynamic-updateDynamic.check14
-rw-r--r--test/files/run/dynamic-updateDynamic.scala28
3 files changed, 45 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index a18bc5ddcf..b80dcefef8 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -4273,7 +4273,9 @@ trait Typers extends Modes with Adaptations with Tags {
}
else if(dyna.isDynamicallyUpdatable(lhs1)) {
val rhs1 = typed(rhs, EXPRmode | BYVALmode, WildcardType)
- val t = Apply(lhs1, List(rhs1))
+ val t = atPos(lhs1.pos.withEnd(rhs1.pos.endOrPoint)) {
+ Apply(lhs1, List(rhs1))
+ }
dyna.wrapErrors(t, _.typed1(t, mode, pt))
}
else fail()
diff --git a/test/files/run/dynamic-updateDynamic.check b/test/files/run/dynamic-updateDynamic.check
new file mode 100644
index 0000000000..3e21b7dfdc
--- /dev/null
+++ b/test/files/run/dynamic-updateDynamic.check
@@ -0,0 +1,14 @@
+[[syntax trees at end of typer]] // newSource1.scala
+[0:69]package [0:0]<empty> {
+ [0:69]object X extends [9:69][69]scala.AnyRef {
+ [9]def <init>(): [9]X.type = [9]{
+ [9][9][9]X.super.<init>();
+ [9]()
+ };
+ [17:30]private[this] val d: [21]D = [25:30][25:30][25:30]new [29:30]D();
+ [21]<stable> <accessor> def d: [21]D = [21][21]X.this.d;
+ [37:49][37:38][37:38][37]X.this.d.updateDynamic(<39:44>"field")([47:49]10);
+ [56:57][56:57][56]X.this.d.selectDynamic(<58:63>"field")
+ }
+}
+
diff --git a/test/files/run/dynamic-updateDynamic.scala b/test/files/run/dynamic-updateDynamic.scala
new file mode 100644
index 0000000000..80fe0ea35f
--- /dev/null
+++ b/test/files/run/dynamic-updateDynamic.scala
@@ -0,0 +1,28 @@
+import scala.tools.partest.DirectTest
+
+object Test extends DirectTest {
+
+ override def extraSettings: String =
+ s"-usejavacp -Xprint-pos -Xprint:typer -Yrangepos -Ystop-after:typer -d ${testOutput.path}"
+
+ override def code = """
+ object X {
+ val d = new D
+ d.field = 10
+ d.field
+ }
+ """.trim
+
+ override def show(): Unit = {
+ Console.withErr(System.out) {
+ compile()
+ }
+ }
+}
+
+import language.dynamics
+class D extends Dynamic {
+ def selectDynamic(name: String): Any = ???
+ def updateDynamic(name: String)(value: Any): Unit = ???
+}
+