Skip to content

Instantly share code, notes, and snippets.

@xeno-by
Created September 8, 2013 21:08
Show Gist options
  • Save xeno-by/6488412 to your computer and use it in GitHub Desktop.
Save xeno-by/6488412 to your computer and use it in GitHub Desktop.
23:08 ~/Projects/210x/sandbox (2.10.x)$ cat Test.scala
class C {
lazy val x = 42
}
23:08 ~/Projects/210x/sandbox (2.10.x)$ scalac Test.scala -Xprint:cleanup
[[syntax trees at end of cleanup]] // Test.scala
package <empty> {
class C extends Object {
@volatile private[this] var bitmap$0: Boolean = false;
private def x$lzycompute(): Int = {
{
C.this.synchronized({
if (C.this.bitmap$0.unary_!())
{
C.this.x = 42;
C.this.bitmap$0 = true;
()
};
scala.runtime.BoxedUnit.UNIT
});
()
};
C.this.x
};
lazy private[this] var x: Int = _;
<stable> <accessor> lazy def x(): Int = if (C.this.bitmap$0.unary_!())
C.this.x$lzycompute()
else
C.this.x;
def <init>(): C = {
C.super.<init>();
()
}
}
}
23:08 ~/Projects/210x/sandbox (2.10.x)$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment