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 lazy vals break binary compatibility #3038

Closed
scabug opened this issue Feb 9, 2010 · 5 comments
Closed

private lazy vals break binary compatibility #3038

scabug opened this issue Feb 9, 2010 · 5 comments
Assignees

Comments

@scabug
Copy link

scabug commented Feb 9, 2010

Using Scala 2.8.0.r20828 and Java 1.6

Because the bitmask for lazy vals is shared by classes in an inheritance chain, adding a private lazy val breaks binary compatibility/separate compilation. Consider A.scala and B.scala:

A.scala

class A {
   lazy val x = 1
}

B.scala

class B extends A {
   lazy val y = 2
}

and a test class in C.scala

object C {
   def main(args: Array[String]) {
      val b = new B
      println( b.x )
      println( b.y )
   }
}

Compiling all files and running C prints

1
2

Change A.scala to use a private lazy val:

class A {
   lazy val x = x2
   private lazy val x2 = 1
}

Recompiling A.scala and running C prints

1
0
@scabug
Copy link
Author

scabug commented Feb 9, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3038?orig=1
Reporter: @harrah

@scabug
Copy link
Author

scabug commented Feb 9, 2010

@paulp said:
Any attempt to address this should also encompass #1573 and #1574. Possibly the lowest impact would be to have a separate bitspace for private lazy vals (and yet another one for transient ones? Hello @transient private lazy good-times!)

@scabug
Copy link
Author

scabug commented Feb 16, 2010

@hubertp said:
As pointed out by Mark, the solution to this ticket can possibly fix #3059 as well.

@scabug
Copy link
Author

scabug commented Oct 22, 2010

@hubertp said:
This should be fairly easy now that fix for #3895 is in place. Note that the actual example above works now, but it reappears if you move x2 before x. Because of the inheritance such situations will happen for public/protected lazy vals but private lazy vals will use private bitmap once I fix this.

@scabug
Copy link
Author

scabug commented Nov 1, 2010

@hubertp said:
(In r23435) Added separate bitmaps for private and transient lazy vals. Closes #3038, #1573. Review by dragos.
I had to fix a couple of initialization issues that checkinit forced me to do and that weren't a problem before because the bitmap was serialized even for @Transitive. For that I needed to change the setters in checkinit so that they also update the bitmap.

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

No branches or pull requests

2 participants