@@ -107,9 +107,7 @@ private[async] final case class AnfTransform[C <: Context](c: C) {
107107 indent += 1
108108 def oneLine (s : Any ) = s.toString.replaceAll( """ \n""" , " \\\\ n" ).take(127 )
109109 try {
110- AsyncUtils .trace(s " ${
111- indentString
112- }$prefix( ${oneLine(args)}) " )
110+ AsyncUtils .trace(s " ${indentString}$prefix( ${oneLine(args)}) " )
113111 val result = t
114112 AsyncUtils .trace(s " ${indentString}= ${oneLine(result)}" )
115113 result
@@ -193,19 +191,19 @@ private[async] final case class AnfTransform[C <: Context](c: C) {
193191 val stats :+ expr = inline.transformToList(qual)
194192 stats :+ attachCopy(tree)(Select (expr, sel).setSymbol(tree.symbol))
195193
196- case utils. Applied (fun, targs, argss @ (args :: rest)) if containsAwait =>
194+ case Applied (fun, targs, argss) if argss.nonEmpty && containsAwait =>
197195 // we an assume that no await call appears in a by-name argument position,
198196 // this has already been checked.
199197 val funStats :+ simpleFun = inline.transformToList(fun)
200198 def isAwaitRef (name : Name ) = name.toString.startsWith(utils.name.await + " $" )
201199 val (argStatss, argExprss): (List [List [List [Tree ]]], List [List [Tree ]]) =
202200 mapArgumentss[List [Tree ]](fun, argss) {
203- case arg if arg.isByName || isSafeToInline(arg. expr) => (Nil , arg. expr)
204- case Arg (arg @ Ident (name), _, _) if isAwaitRef(name) => (Nil , arg ) // not typed, so it eludes the check in `isSafeToInline`
205- case arg =>
206- inline .transformToList(arg. expr) match {
207- case stats :+ expr =>
208- val valDef = defineVal(arg. argName, expr, arg. expr.pos)
201+ case Arg (expr, byName, _) if byName || isSafeToInline(expr) => (Nil , expr)
202+ case Arg (expr @ Ident (name), _, _) if isAwaitRef(name) => (Nil , expr ) // not typed, so it eludes the check in `isSafeToInline`
203+ case Arg (expr, _, argName) =>
204+ inline .transformToList(expr) match {
205+ case stats :+ expr1 =>
206+ val valDef = defineVal(argName, expr1, expr.pos)
209207 (stats :+ valDef, Ident (valDef.name))
210208 }
211209 }
0 commit comments