From 92ab5b74abcff8b49a408f4bf46c285c0016a44b Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sat, 5 Apr 2014 23:12:58 +0200 Subject: Refactoring in ANFTransform - simpler means to calculate `applyDepth` - remove unused binder --- src/main/scala/scala/async/internal/AnfTransform.scala | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/main/scala/scala/async/internal/AnfTransform.scala b/src/main/scala/scala/async/internal/AnfTransform.scala index a0f722f..e54eb54 100644 --- a/src/main/scala/scala/async/internal/AnfTransform.scala +++ b/src/main/scala/scala/async/internal/AnfTransform.scala @@ -161,7 +161,7 @@ private[async] trait AnfTransform { val stats :+ expr1 = linearize.transformToList(expr) stats :+ treeCopy.Typed(tree, expr1, tpt) - case ap @ Applied(fun, targs, argss) if argss.nonEmpty => + case Applied(fun, targs, argss) if argss.nonEmpty => // we can assume that no await call appears in a by-name argument position, // this has already been checked. val funStats :+ simpleFun = linearize.transformToList(fun) @@ -188,20 +188,7 @@ private[async] trait AnfTransform { } } - /** The depth of the nested applies: e.g. Apply(Apply(Apply(_, _), _), _) - * has depth 3. Continues through type applications (without counting them.) - */ - def applyDepth: Int = { - def loop(tree: Tree): Int = tree match { - case Apply(fn, _) => 1 + loop(fn) - case TypeApply(fn, _) => loop(fn) - case AppliedTypeTree(fn, _) => loop(fn) - case _ => 0 - } - loop(tree) - } - - val typedNewApply = copyApplied(tree, applyDepth) + val typedNewApply = copyApplied(tree, argss.length) funStats ++ argStatss.flatten.flatten :+ typedNewApply -- cgit v1.2.3