@@ -59,7 +59,7 @@ private[async] final case class AnfTransform[C <: Context](c: C) {
59
59
val origName = defTree.symbol.name
60
60
val sym = defTree.symbol.asInstanceOf [symtab.Symbol ]
61
61
val fresh = name.fresh(sym.name.toString)
62
- sym.name = defTree.symbol.name match {
62
+ sym.name = origName match {
63
63
case _ : TermName => symtab.newTermName(fresh)
64
64
case _ : TypeName => symtab.newTypeName(fresh)
65
65
}
@@ -184,14 +184,15 @@ private[async] final case class AnfTransform[C <: Context](c: C) {
184
184
private object anf {
185
185
186
186
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) =>
191
192
val stats :+ expr = inline.transformToList(qual)
192
193
stats :+ attachCopy(tree)(Select (expr, sel).setSymbol(tree.symbol))
193
194
194
- case Applied (fun, targs, argss) if argss.nonEmpty && containsAwait =>
195
+ case Applied (fun, targs, argss) if argss.nonEmpty =>
195
196
// we an assume that no await call appears in a by-name argument position,
196
197
// this has already been checked.
197
198
val funStats :+ simpleFun = inline.transformToList(fun)
@@ -210,20 +211,20 @@ private[async] final case class AnfTransform[C <: Context](c: C) {
210
211
val core = if (targs.isEmpty) simpleFun else TypeApply (simpleFun, targs)
211
212
val newApply = argExprss.foldLeft(core)(Apply (_, _).setSymbol(tree.symbol))
212
213
funStats ++ argStatss.flatten.flatten :+ attachCopy(tree)(newApply)
213
- case Block (stats, expr) if containsAwait =>
214
+ case Block (stats, expr) =>
214
215
inline.transformToList(stats :+ expr)
215
216
216
- case ValDef (mods, name, tpt, rhs) if containsAwait =>
217
+ case ValDef (mods, name, tpt, rhs) =>
217
218
if (rhs exists isAwait) {
218
219
val stats :+ expr = inline.transformToList(rhs)
219
220
stats :+ attachCopy(tree)(ValDef (mods, name, tpt, expr).setSymbol(tree.symbol))
220
221
} else List (tree)
221
222
222
- case Assign (lhs, rhs) if containsAwait =>
223
+ case Assign (lhs, rhs) =>
223
224
val stats :+ expr = inline.transformToList(rhs)
224
225
stats :+ attachCopy(tree)(Assign (lhs, expr))
225
226
226
- case If (cond, thenp, elsep) if containsAwait =>
227
+ case If (cond, thenp, elsep) =>
227
228
val condStats :+ condExpr = inline.transformToList(cond)
228
229
val thenBlock = inline.transformToBlock(thenp)
229
230
val elseBlock = inline.transformToBlock(elsep)
@@ -237,7 +238,7 @@ private[async] final case class AnfTransform[C <: Context](c: C) {
237
238
condStats :+
238
239
attachCopy(tree)(If (condExpr, thenBlock, elseBlock)).setType(ifType)
239
240
240
- case Match (scrut, cases) if containsAwait =>
241
+ case Match (scrut, cases) =>
241
242
val scrutStats :+ scrutExpr = inline.transformToList(scrut)
242
243
val caseDefs = cases map {
243
244
case CaseDef (pat, guard, body) =>
@@ -259,10 +260,10 @@ private[async] final case class AnfTransform[C <: Context](c: C) {
259
260
val typedMatch = attachCopy(tree)(Match (scrutExpr, caseDefs)).setType(tree.tpe)
260
261
scrutStats :+ typedMatch
261
262
262
- case LabelDef (name, params, rhs) if containsAwait =>
263
+ case LabelDef (name, params, rhs) =>
263
264
List (LabelDef (name, params, Block (inline.transformToList(rhs), Literal (Constant (())))).setSymbol(tree.symbol))
264
265
265
- case TypeApply (fun, targs) if containsAwait =>
266
+ case TypeApply (fun, targs) =>
266
267
val funStats :+ simpleFun = inline.transformToList(fun)
267
268
funStats :+ attachCopy(tree)(TypeApply (simpleFun, targs).setSymbol(tree.symbol))
268
269
0 commit comments