diff options
author | Martin Odersky <odersky@gmail.com> | 2008-01-23 15:32:34 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2008-01-23 15:32:34 +0000 |
commit | 628029724b6ebc987aa38d80d72e061d52f5c66d (patch) | |
tree | a57b431deb55c5ce1dafb6015473dbded02903a6 /src | |
parent | b355de5a086c036e8d9c35459e4558053e425603 (diff) | |
download | scala-628029724b6ebc987aa38d80d72e061d52f5c66d.tar.gz scala-628029724b6ebc987aa38d80d72e061d52f5c66d.tar.bz2 scala-628029724b6ebc987aa38d80d72e061d52f5c66d.zip |
trys with returns are lifted when target is MSIL
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/UnCurry.scala | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index a013c4ea04..362a001f9d 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -373,6 +373,21 @@ abstract class UnCurry extends InfoTransform with TypingTransformers { t } + /** A try needs to be lifted anyway for MSIL if it contains + * return statements. These are disallowed in the CLR. By lifting + * such returns will be converted to throws. + */ + def shouldBeLiftedAnyway(tree: Tree) = { + forMSIL && { + var returnFound = false + for (subtree <- tree) subtree match { + case Return(_) => returnFound = true + case _ => + } + returnFound + } + } + def withInConstructorFlag(inConstructorFlag: Long)(f: => Tree): Tree = { val savedInConstructorFlag = this.inConstructorFlag this.inConstructorFlag = inConstructorFlag @@ -449,7 +464,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers { withNeedLift(true) { super.transform(tree) } case Try(block, catches, finalizer) => - if (needTryLift) { + if (needTryLift || shouldBeLiftedAnyway(tree)) { if (settings.debug.value) log("lifting try at: " + (tree.pos)); |