New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiler bug for updateDynamic invocations within expressions #5733
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5733?orig=1 |
@dgruntz said: private[this] val foo: A = new A();
Test.this.foo.updateDynamic("xxx")(3);
scala.this.Predef.println(foo.xxx = 3);
private[this] val x: <error> = foo.xxx = 3.==() |
@harrah said: |
Alexis Agahi (alag) said (edited on Oct 14, 2012 1:04:21 PM UTC): // src/AB.scala
import language.dynamics
object A extends Dynamic {
var a = "a"
def selectDynamic(method:String): String = a
def updateDynamic(method:String)(v:String) { a = v }
}
class B extends Dynamic {
var b = "b"
def selectDynamic(method:String): String = b
def updateDynamic(method:String)(v:String) { b = v }
}
object TestApp extends App {
assert( A.foo == "a" )
assert( A.bar == "a" )
A.aaa = "aaa"
assert( A.bar == "aaa" )
val b = new B
assert( b.foo == "b" )
assert( b.bar == "b" )
b.bbb = "bbb"
assert( b.bar == "bbb" )
println("Done")
} // test/ABTest.scala
import org.junit.Test
import language.dynamics
class ABTest {
@Test
def test() {
assert( A.foo == "a" )
assert( A.bar == "a" )
A.aaa = "aaa"
assert( A.bar == "aaa" )
val b = new B
assert( b.foo == "b" )
assert( b.bar == "b" )
b.bbb = "bbb"
assert( b.bar == "bbb" )
}
} // build.sbt
scalaVersion := "2.10.0-RC1"
scalaSource in Compile <<= baseDirectory(_ / "src")
scalaSource in Test <<= baseDirectory(_ / "test")
libraryDependencies += "com.novocode" % "junit-interface" % "0.10-M1" % "test"
libraryDependencies += "org.scala-lang" % "scala-reflect" % "2.10.0-RC1"
libraryDependencies += "org.scala-lang" % "scala-compiler" % "2.10.0-RC1"
|
@paulp said: |
@retronym said: |
Problem with
updateDynamic
:\
If a dynamic field assignment is invoked within an expression (the type of the assignment invocation depends on the result type of method
updateDynamic
), then the compiler reports the errorreassignment to val
.The text was updated successfully, but these errors were encountered: