Disallow non-local returns in tryTest{}

Non-local returns will prevent the execution of the cleanup{}
block, which is too much of a footgun to allow. See the bug
for details of how it happens.

There doesn't seem to be a way to keep the nice syntax, allow
non-local returns and still guarantee execution of the cleanup
block in all cases. Thus, forbid non-local returns. Users can
still use return@tryTest to accomplish almost the same thing,
and the next patch will also let tryTest{} return its last
evaluated value, fixing remaining cases.

E.g.
tryTest {
  foo()
  if (condition) return result
  bar()
} cleanup {
  doCleanup()
}

can always be written

return tryTest {
  foo()
  if (condition) return@tryTest result
  bar()
} cleanup {
  doCleanup()
}

...and it's a rare case, so the additional syntax is acceptable.

Test: NetworkStaticLibTests
Bug: 207358921
Change-Id: I40443acf7e4d86813641adc877e27fb2334d0daf
1 file changed
tree: 033164fb6bf68c47a977c0c6c5777570ae5c2cb9
  1. staticlibs/