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

private[this] constructor var shadows itself #6880

Closed
scabug opened this issue Dec 26, 2012 · 1 comment
Closed

private[this] constructor var shadows itself #6880

scabug opened this issue Dec 26, 2012 · 1 comment
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Dec 26, 2012

class Example(private[this] var con1: Int, private var con2: Int) {
  private[this] var field1: Int = -3
  private var field2: Int = -3

  println("[constructor, before] " + ((con1, con2, field1, field2)))
  con1 = 75
  con2 = 75
  field1 = 75
  field2 = 75
  println("[constructor, after] " + ((con1, con2, field1, field2)))

  def xValue = ((con1, con2, field1, field2))
}

object Test {
  def main(args: Array[String]) {
    val example = new Example(-3, -3)
    println("[post-constructor] " + example.xValue) // prints -3, expected 0.
  }
}

This prints:

[constructor, before] (-3,-3,-3,-3)
[constructor, after] (75,75,75,75)
[post-constructor] (-3,75,75,75)
@scabug
Copy link
Author

scabug commented Dec 26, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6880?orig=1
Reporter: @paulp
Affected Versions: 2.10.0
See #4762

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

No branches or pull requests

3 participants