Or an alternative where the method creates an AutoCloseable instance that fits into a try-with-resources:
class Foo {
def bar() {
try (push(field1 = value); push(field2)) {
baz()
}
}
}
"push" would create something that has read/write access to "field1".
Assignment "field1 = value" happens in constructor and "field1 = <previous
value>" happens in the close() method.
