Skip to content
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

updateDynamic is not used in some contexts #5726

Closed
scabug opened this issue Apr 30, 2012 · 3 comments
Closed

updateDynamic is not used in some contexts #5726

scabug opened this issue Apr 30, 2012 · 3 comments

Comments

@scabug
Copy link

scabug commented Apr 30, 2012

I discovered strange behavior of updateDynamic. I trying to compile following code:

import language.dynamics

class DynamicTest extends Dynamic {
  def selectDynamic(name: String) = s"value of $name"
  def updateDynamic(name: String)(value: Any) {
    println(s"You have just updated property '$name' with value: $value")
  }
}

object MyApp extends App {
  def testing() {
    val test = new DynamicTest
    test.firstName = "John"
  }
  
  testing()
}

Which produces following compilation error:

# scalac MyApp.scala
MyApp.scala:13: error: reassignment to val
    test.firstName = "John"
                   ^

one error found

If I will remove selectDynamic method from the DynamicTest I will receive another error: "error: value selectDynamic is not a member of DynamicTest".

If I will define MyApp class like this:

object MyApp extends App {
  val test = new DynamicTest

  test.firstName = "John"
}

Then everything compiles without any errors.

BTW, I'm facing the same errors in the REPL.

@scabug
Copy link
Author

scabug commented Apr 30, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5726?orig=1
Reporter: Oleg Ilyenko (oleg.ilyenko)
Affected Versions: 2.10.0-M3
Other Milestones: 2.10.0

@scabug
Copy link
Author

scabug commented Nov 28, 2012

@paulp said:
scala/scala#1681

@scabug
Copy link
Author

scabug commented Dec 5, 2012

@retronym said:
scala/scala@edbcc64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants