@@ -27,7 +27,6 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
2727
2828 class ANFTransformer (unit : CompilationUnit ) extends TypingTransformer (unit) {
2929
30- implicit val _unit = unit // allow code in CPSUtils.scala to report errors
3130 var cpsAllowed : Boolean = false // detect cps code in places we do not handle (yet)
3231
3332 object RemoveTailReturnsTransformer extends Transformer {
@@ -63,7 +62,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
6362 treeCopy.CaseDef (tree, pat, guard, transform(body))
6463
6564 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" )
6766 tree
6867
6968 case _ =>
@@ -178,7 +177,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
178177 treeCopy.ValDef (vd, mods, name, transform(tpt), rhs1)
179178 }
180179 } 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" )
182181 super .transform(tree)
183182 }
184183
@@ -195,9 +194,9 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
195194 if (hasAnswerTypeAnn(tree.tpe)) {
196195 if (! cpsAllowed) {
197196 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" )
199198 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)
201200 }
202201 log(tree)
203202 }
@@ -268,10 +267,10 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
268267 // check that then and else parts agree (not necessary any more, but left as sanity check)
269268 if (cpsR.isDefined) {
270269 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" )
272271 }
273272 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" )
275274 }
276275
277276 (condStats, updateSynthFlag(treeCopy.If (tree, condVal, thenVal, elseVal)), spc)
@@ -341,7 +340,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
341340
342341 case Return (expr0) =>
343342 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" )
345344 val (stms, expr, spc) = transInlineValue(expr0, cpsA)
346345 (stms, updateSynthFlag(treeCopy.Return (tree, expr)), spc)
347346
@@ -384,7 +383,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
384383
385384 val (stms, expr, spc) = transValue(tree, cpsA, cpsR)
386385
387- val bot = linearize(spc, getAnswerTypeAnn(expr.tpe))(unit, tree.pos)
386+ val bot = linearize(spc, getAnswerTypeAnn(expr.tpe))(tree.pos)
388387
389388 val plainTpe = removeAllCPSAnnotations(expr.tpe)
390389
@@ -425,13 +424,13 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
425424 // TODO - obviously this should be done earlier, differently, or with
426425 // a more skilled hand. Most likely, all three.
427426 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" )
429428 else
430429 return ((stms, call))
431430 }
432431 catch {
433432 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)
435434 }
436435 }
437436
@@ -442,7 +441,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
442441
443442 // println(cpsR + "/" + spc + "/" + bot)
444443
445- unit .error(tree.pos, " found cps expression in non-cps position" )
444+ reporter .error(tree.pos, " found cps expression in non-cps position" )
446445 } else {
447446 // all is well
448447
@@ -474,7 +473,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
474473 expr.changeOwner(currentOwner -> sym)
475474
476475 (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))
478477
479478 case _ =>
480479 (stms, expr, spc)
@@ -503,12 +502,12 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
503502 val spcVal = getAnswerTypeAnn(anfRhs.tpe)
504503 spcVal foreach (_ => tree.symbol setAnnotations List (AnnotationInfo (MarkerCPSSym .tpe_* , Nil , Nil )))
505504
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))
507506
508507 case _ =>
509508 val (headStms, headExpr, headSpc) = transInlineValue(stm, cpsA)
510509 val valSpc = getAnswerTypeAnn(headExpr.tpe)
511- (headStms::: List (headExpr), linearize(headSpc, valSpc)(unit, stm.pos))
510+ (headStms::: List (headExpr), linearize(headSpc, valSpc)(stm.pos))
512511 }
513512 }
514513
0 commit comments