summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/UnCurry.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2008-01-24 11:36:36 +0000
committerMartin Odersky <odersky@gmail.com>2008-01-24 11:36:36 +0000
commit23b18671a24cb192096e6ed98d6db65b006b833b (patch)
tree88010c55b97fc1487bcb33fa14370eeb5ced3dcc /src/compiler/scala/tools/nsc/transform/UnCurry.scala
parentfb51361c652acab3f624ca178b187810e82c6587 (diff)
downloadscala-23b18671a24cb192096e6ed98d6db65b006b833b.tar.gz
scala-23b18671a24cb192096e6ed98d6db65b006b833b.tar.bz2
scala-23b18671a24cb192096e6ed98d6db65b006b833b.zip
fixed problem with recursive lifting in MSIL
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/UnCurry.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala30
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
*/