class Foo(x: Int) {
private[this] var init = false;
lazy val foo = {
if (!init) {
init = true
assert(false)
}
x
}
}
object Test {
def main(args: Array[String]): Unit = {
val foo = new Foo(42)
try foo.foo
catch {
case _: AssertionError =>
println(foo.foo) // prints 0, should be 42
}
}
}