Permalink
Browse files

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.
  • Loading branch information...
kiritsuku authored and retronym committed Nov 23, 2013
1 parent 696545d commit 3629b645cc2b1403c51925dd9c696a57008c0ce2
@@ -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()
@@ -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")
}
}
@@ -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 = ???
}

0 comments on commit 3629b64

Please sign in to comment.