Skip to content

Fields for final var not found. #1878

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

Closed
nicolasstucki opened this issue Jan 4, 2017 · 1 comment
Closed

Fields for final var not found. #1878

nicolasstucki opened this issue Jan 4, 2017 · 1 comment

Comments

@nicolasstucki
Copy link
Contributor

When we declare a final var and then assign a new value we get a NoSuchFieldError.

object Test {
  def main(args: Array[String]): Unit = {
    NoStackTrace2._noSuppression = true
  }
}

object NoStackTrace2 {
  final var _noSuppression: Boolean = false
}
java.lang.NoSuchFieldError: _noSuppression$$local
	at NoStackTrace2$._noSuppression_$eq(test.scala:8)
	at Test$.main(test.scala:3)
	at Test.main(test.scala)

In the byte code we get:

public final class NoStackTrace2$ {
    ...
    public boolean _noSuppression() {
        return false;
    }
    public void _noSuppression_$eq(boolean x$1) {
        this._noSuppression$$local = x$1;
    }
}

Which makes me think that we are handling final var as a final val at some point because the false initial value was inlined in the getter and the field is not there.

@smarter
Copy link
Member

smarter commented Jan 4, 2017

Probably related: #1348 (comment)

@nicolasstucki nicolasstucki self-assigned this Jan 5, 2017
@odersky odersky closed this as completed in 63d68bf Jan 5, 2017
odersky added a commit that referenced this issue Jan 5, 2017
Fix #1878: Generate fields for final vars.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 5, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 9, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 10, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 10, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 10, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 11, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 12, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 12, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 27, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 9, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 13, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 16, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 21, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 22, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 2, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 2, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 15, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 16, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 20, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 20, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 27, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 29, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 30, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 31, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 3, 2017
nicolasstucki added a commit to nicolasstucki/dotty that referenced this issue Apr 6, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 7, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 10, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 12, 2017
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

3 participants