scala/scala — pull request #987 by phaller (2012-07-24 18:54:20+00:00)
Title: SI-5314 - CPS transform of return statement fails

SI-5314 - CPS transform of return statement fails

Enable return expressions in CPS code if they are in tail position. Note that tail returns are
only removed in methods that do not call `shift` or `reset` (otherwise, an error is reported).

Addresses the issues pointed out in a previous pull request:
https://github.com/scala/scala/pull/720

- Addresses all issues mentioned here:
https://github.com/scala/scala/pull/720#issuecomment-6429705

- Replaces explicit context stack with another hook in the AnnotationChecker interface,
as suggested by @TiarkRompf here:
https://github.com/scala/scala/pull/720#commitcomment-1477464

- Move transformation methods to SelectiveANFTransform.scala:
https://github.com/scala/scala/pull/720#commitcomment-1477497

- Do not keep a list of tail returns.

- No separate traversal for issuing non-tail errors.

Tests:

- continuations-neg/t5314-missing-result-type.scala
- continuations-neg/t5314-type-error.scala
- continuations-neg/t5314-npe.scala
- continuations-run/t5314.scala
- continuations-run/t5314-2.scala
- continuations-run/t5314-3.scala

Review by @TiarkRompf and @adriaanm