diff options
author | Martin Odersky <odersky@gmail.com> | 2008-01-24 11:36:36 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2008-01-24 11:36:36 +0000 |
commit | 23b18671a24cb192096e6ed98d6db65b006b833b (patch) | |
tree | 88010c55b97fc1487bcb33fa14370eeb5ced3dcc | |
parent | fb51361c652acab3f624ca178b187810e82c6587 (diff) | |
download | scala-23b18671a24cb192096e6ed98d6db65b006b833b.tar.gz scala-23b18671a24cb192096e6ed98d6db65b006b833b.tar.bz2 scala-23b18671a24cb192096e6ed98d6db65b006b833b.zip |
fixed problem with recursive lifting in MSIL
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/UnCurry.scala | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index bce119c494..c7cacc4639 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -102,6 +102,24 @@ abstract class UnCurry extends InfoTransform with TypingTransformers { def transformInfo(sym: Symbol, tp: Type): Type = if (sym.isType) uncurryType(tp) else uncurry(tp) + /** Traverse tree omitting local method definitions. + * If a `return' is encountered, set `returnFound' to true. + * Used for MSIL only. + */ + private object lookForReturns extends TreeTraverser { + var returnFound = false + override def traverse(tree: Tree): Unit = tree match { + case Return(_) => returnFound = true + case DefDef(_, _, _, _, _, _) => ; + case _ => super.traverse(tree) + } + def found(tree: Tree) = { + returnFound = false + traverse(tree) + returnFound + } + } + class UnCurryTransformer(unit: CompilationUnit) extends TypingTransformer(unit) { private var needTryLift = false @@ -377,16 +395,8 @@ abstract class UnCurry extends InfoTransform with TypingTransformers { * 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 shouldBeLiftedAnyway(tree: Tree) = + forMSIL && lookForReturns.found(tree) /** Transform tree `t' to { def f = t; f } where `f' is a fresh name */ |