@@ -27,7 +27,6 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
27
27
28
28
class ANFTransformer (unit : CompilationUnit ) extends TypingTransformer (unit) {
29
29
30
- implicit val _unit = unit // allow code in CPSUtils.scala to report errors
31
30
var cpsAllowed : Boolean = false // detect cps code in places we do not handle (yet)
32
31
33
32
object RemoveTailReturnsTransformer extends Transformer {
@@ -63,7 +62,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
63
62
treeCopy.CaseDef (tree, pat, guard, transform(body))
64
63
65
64
case Return (_) =>
66
- unit .error(tree.pos, " return expressions in CPS code must be in tail position" )
65
+ reporter .error(tree.pos, " return expressions in CPS code must be in tail position" )
67
66
tree
68
67
69
68
case _ =>
@@ -178,7 +177,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
178
177
treeCopy.ValDef (vd, mods, name, transform(tpt), rhs1)
179
178
}
180
179
} else {
181
- unit .error(tree.pos, " cps annotations not allowed on by-value parameters or value definitions" )
180
+ reporter .error(tree.pos, " cps annotations not allowed on by-value parameters or value definitions" )
182
181
super .transform(tree)
183
182
}
184
183
@@ -195,9 +194,9 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
195
194
if (hasAnswerTypeAnn(tree.tpe)) {
196
195
if (! cpsAllowed) {
197
196
if (tree.symbol.isLazy)
198
- unit .error(tree.pos, " implementation restriction: cps annotations not allowed on lazy value definitions" )
197
+ reporter .error(tree.pos, " implementation restriction: cps annotations not allowed on lazy value definitions" )
199
198
else
200
- unit .error(tree.pos, " cps code not allowed here / " + tree.getClass + " / " + tree)
199
+ reporter .error(tree.pos, " cps code not allowed here / " + tree.getClass + " / " + tree)
201
200
}
202
201
log(tree)
203
202
}
@@ -268,10 +267,10 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
268
267
// check that then and else parts agree (not necessary any more, but left as sanity check)
269
268
if (cpsR.isDefined) {
270
269
if (elsep == EmptyTree )
271
- unit .error(tree.pos, " always need else part in cps code" )
270
+ reporter .error(tree.pos, " always need else part in cps code" )
272
271
}
273
272
if (hasAnswerTypeAnn(thenVal.tpe) != hasAnswerTypeAnn(elseVal.tpe)) {
274
- unit .error(tree.pos, " then and else parts must both be cps code or neither of them" )
273
+ reporter .error(tree.pos, " then and else parts must both be cps code or neither of them" )
275
274
}
276
275
277
276
(condStats, updateSynthFlag(treeCopy.If (tree, condVal, thenVal, elseVal)), spc)
@@ -341,7 +340,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
341
340
342
341
case Return (expr0) =>
343
342
if (isAnyParentImpure)
344
- unit .error(tree.pos, " return expression not allowed, since method calls CPS method" )
343
+ reporter .error(tree.pos, " return expression not allowed, since method calls CPS method" )
345
344
val (stms, expr, spc) = transInlineValue(expr0, cpsA)
346
345
(stms, updateSynthFlag(treeCopy.Return (tree, expr)), spc)
347
346
@@ -384,7 +383,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
384
383
385
384
val (stms, expr, spc) = transValue(tree, cpsA, cpsR)
386
385
387
- val bot = linearize(spc, getAnswerTypeAnn(expr.tpe))(unit, tree.pos)
386
+ val bot = linearize(spc, getAnswerTypeAnn(expr.tpe))(tree.pos)
388
387
389
388
val plainTpe = removeAllCPSAnnotations(expr.tpe)
390
389
@@ -425,13 +424,13 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
425
424
// TODO - obviously this should be done earlier, differently, or with
426
425
// a more skilled hand. Most likely, all three.
427
426
if ((b.typeSymbol eq NothingClass ) && call.tpe.exists(_ eq WildcardType ))
428
- unit .error(tree.pos, " cannot cps-transform malformed (possibly in shift/reset placement) expression" )
427
+ reporter .error(tree.pos, " cannot cps-transform malformed (possibly in shift/reset placement) expression" )
429
428
else
430
429
return ((stms, call))
431
430
}
432
431
catch {
433
432
case ex: TypeError =>
434
- unit .error(ex.pos, " cannot cps-transform expression " + tree + " : " + ex.msg)
433
+ reporter .error(ex.pos, " cannot cps-transform expression " + tree + " : " + ex.msg)
435
434
}
436
435
}
437
436
@@ -442,7 +441,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
442
441
443
442
// println(cpsR + "/" + spc + "/" + bot)
444
443
445
- unit .error(tree.pos, " found cps expression in non-cps position" )
444
+ reporter .error(tree.pos, " found cps expression in non-cps position" )
446
445
} else {
447
446
// all is well
448
447
@@ -474,7 +473,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
474
473
expr.changeOwner(currentOwner -> sym)
475
474
476
475
(stms ::: List (ValDef (sym, expr) setType(NoType )),
477
- Ident (sym) setType(valueTpe) setPos(tree.pos), linearize(spc, spcVal)(unit, tree.pos))
476
+ Ident (sym) setType(valueTpe) setPos(tree.pos), linearize(spc, spcVal)(tree.pos))
478
477
479
478
case _ =>
480
479
(stms, expr, spc)
@@ -503,12 +502,12 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
503
502
val spcVal = getAnswerTypeAnn(anfRhs.tpe)
504
503
spcVal foreach (_ => tree.symbol setAnnotations List (AnnotationInfo (MarkerCPSSym .tpe_* , Nil , Nil )))
505
504
506
- (stms::: List (treeCopy.ValDef (tree, mods, name, tpt, anfRhs)), linearize(spc, spcVal)(unit, tree.pos))
505
+ (stms::: List (treeCopy.ValDef (tree, mods, name, tpt, anfRhs)), linearize(spc, spcVal)(tree.pos))
507
506
508
507
case _ =>
509
508
val (headStms, headExpr, headSpc) = transInlineValue(stm, cpsA)
510
509
val valSpc = getAnswerTypeAnn(headExpr.tpe)
511
- (headStms::: List (headExpr), linearize(headSpc, valSpc)(unit, stm.pos))
510
+ (headStms::: List (headExpr), linearize(headSpc, valSpc)(stm.pos))
512
511
}
513
512
}
514
513
0 commit comments