Skip to content

Commit 92ab5b7

Browse files
committed
Refactoring in ANFTransform
- simpler means to calculate `applyDepth` - remove unused binder
1 parent 9389830 commit 92ab5b7

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/main/scala/scala/async/internal/AnfTransform.scala

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private[async] trait AnfTransform {
161161
val stats :+ expr1 = linearize.transformToList(expr)
162162
stats :+ treeCopy.Typed(tree, expr1, tpt)
163163

164-
case ap @ Applied(fun, targs, argss) if argss.nonEmpty =>
164+
case Applied(fun, targs, argss) if argss.nonEmpty =>
165165
// we can assume that no await call appears in a by-name argument position,
166166
// this has already been checked.
167167
val funStats :+ simpleFun = linearize.transformToList(fun)
@@ -188,20 +188,7 @@ private[async] trait AnfTransform {
188188
}
189189
}
190190

191-
/** The depth of the nested applies: e.g. Apply(Apply(Apply(_, _), _), _)
192-
* has depth 3. Continues through type applications (without counting them.)
193-
*/
194-
def applyDepth: Int = {
195-
def loop(tree: Tree): Int = tree match {
196-
case Apply(fn, _) => 1 + loop(fn)
197-
case TypeApply(fn, _) => loop(fn)
198-
case AppliedTypeTree(fn, _) => loop(fn)
199-
case _ => 0
200-
}
201-
loop(tree)
202-
}
203-
204-
val typedNewApply = copyApplied(tree, applyDepth)
191+
val typedNewApply = copyApplied(tree, argss.length)
205192

206193
funStats ++ argStatss.flatten.flatten :+ typedNewApply
207194

0 commit comments

Comments
 (0)