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

Comments

Projects
None yet
2 participants
@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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Author

scabug commented Nov 28, 2012

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Dec 5, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.