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

IllegalAccessError when accessing private[this] variable from outer closure #4643

Closed
scabug opened this issue May 25, 2011 · 2 comments
Closed
Assignees

Comments

@scabug
Copy link

scabug commented May 25, 2011

The code below compiles but throws an IllegalAccessError because of the private[this] access modifier.

object FinalVar {
  class Foo(private[this] final var i:Int) {
    def update(k:(Int => Unit) => Unit) = k{j => i = j}
  }
  def main(args : Array[String]) : Unit = {
    val foo = new Foo(0)
    foo.update(_(3))
  }
}
@scabug
Copy link
Author

scabug commented May 25, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4643?orig=1
Reporter: @sbocq
Affected Versions: 2.8.1, 2.9.0

@scabug
Copy link
Author

scabug commented Jun 14, 2011

@paulp said:
Close enough to a duplicate of #3569. (It has to be both final and private[this].) I added a pointer there.

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