@@ -59,7 +59,7 @@ private[async] final case class AnfTransform[C <: Context](c: C) {
5959 val origName = defTree.symbol.name
6060 val sym = defTree.symbol.asInstanceOf [symtab.Symbol ]
6161 val fresh = name.fresh(sym.name.toString)
62- sym.name = defTree.symbol.name match {
62+ sym.name = origName match {
6363 case _ : TermName => symtab.newTermName(fresh)
6464 case _ : TypeName => symtab.newTypeName(fresh)
6565 }
@@ -184,14 +184,15 @@ private[async] final case class AnfTransform[C <: Context](c: C) {
184184 private object anf {
185185
186186 private [AnfTransform ] def transformToList (tree : Tree ): List [Tree ] = trace(" anf" , tree) {
187- def containsAwait = tree exists isAwait
188-
189- tree match {
190- case Select (qual, sel) if containsAwait =>
187+ val containsAwait = tree exists isAwait
188+ if (! containsAwait) {
189+ List (tree)
190+ } else tree match {
191+ case Select (qual, sel) =>
191192 val stats :+ expr = inline.transformToList(qual)
192193 stats :+ attachCopy(tree)(Select (expr, sel).setSymbol(tree.symbol))
193194
194- case Applied (fun, targs, argss) if argss.nonEmpty && containsAwait =>
195+ case Applied (fun, targs, argss) if argss.nonEmpty =>
195196 // we an assume that no await call appears in a by-name argument position,
196197 // this has already been checked.
197198 val funStats :+ simpleFun = inline.transformToList(fun)
@@ -210,20 +211,20 @@ private[async] final case class AnfTransform[C <: Context](c: C) {
210211 val core = if (targs.isEmpty) simpleFun else TypeApply (simpleFun, targs)
211212 val newApply = argExprss.foldLeft(core)(Apply (_, _).setSymbol(tree.symbol))
212213 funStats ++ argStatss.flatten.flatten :+ attachCopy(tree)(newApply)
213- case Block (stats, expr) if containsAwait =>
214+ case Block (stats, expr) =>
214215 inline.transformToList(stats :+ expr)
215216
216- case ValDef (mods, name, tpt, rhs) if containsAwait =>
217+ case ValDef (mods, name, tpt, rhs) =>
217218 if (rhs exists isAwait) {
218219 val stats :+ expr = inline.transformToList(rhs)
219220 stats :+ attachCopy(tree)(ValDef (mods, name, tpt, expr).setSymbol(tree.symbol))
220221 } else List (tree)
221222
222- case Assign (lhs, rhs) if containsAwait =>
223+ case Assign (lhs, rhs) =>
223224 val stats :+ expr = inline.transformToList(rhs)
224225 stats :+ attachCopy(tree)(Assign (lhs, expr))
225226
226- case If (cond, thenp, elsep) if containsAwait =>
227+ case If (cond, thenp, elsep) =>
227228 val condStats :+ condExpr = inline.transformToList(cond)
228229 val thenBlock = inline.transformToBlock(thenp)
229230 val elseBlock = inline.transformToBlock(elsep)
@@ -237,7 +238,7 @@ private[async] final case class AnfTransform[C <: Context](c: C) {
237238 condStats :+
238239 attachCopy(tree)(If (condExpr, thenBlock, elseBlock)).setType(ifType)
239240
240- case Match (scrut, cases) if containsAwait =>
241+ case Match (scrut, cases) =>
241242 val scrutStats :+ scrutExpr = inline.transformToList(scrut)
242243 val caseDefs = cases map {
243244 case CaseDef (pat, guard, body) =>
@@ -259,10 +260,10 @@ private[async] final case class AnfTransform[C <: Context](c: C) {
259260 val typedMatch = attachCopy(tree)(Match (scrutExpr, caseDefs)).setType(tree.tpe)
260261 scrutStats :+ typedMatch
261262
262- case LabelDef (name, params, rhs) if containsAwait =>
263+ case LabelDef (name, params, rhs) =>
263264 List (LabelDef (name, params, Block (inline.transformToList(rhs), Literal (Constant (())))).setSymbol(tree.symbol))
264265
265- case TypeApply (fun, targs) if containsAwait =>
266+ case TypeApply (fun, targs) =>
266267 val funStats :+ simpleFun = inline.transformToList(fun)
267268 funStats :+ attachCopy(tree)(TypeApply (simpleFun, targs).setSymbol(tree.symbol))
268269
0 commit comments