diff options
author | Paul Phillips <paulp@improving.org> | 2012-11-30 06:01:17 +0100 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-12-27 15:47:32 -0800 |
commit | 2e3e43b5971ab93b04ab4677fe23a81bb3291470 (patch) | |
tree | e2e02e50d11845c04c4f67d1aa1f4005bf89ce14 /src/continuations | |
parent | bf253b8983ec3a2807d2137a9e29b732135eb2dc (diff) | |
download | scala-2e3e43b5971ab93b04ab4677fe23a81bb3291470.tar.gz scala-2e3e43b5971ab93b04ab4677fe23a81bb3291470.tar.bz2 scala-2e3e43b5971ab93b04ab4677fe23a81bb3291470.zip |
Eliminate allocations in CPSAnnotationChecker.
Diffstat (limited to 'src/continuations')
-rw-r--r-- | src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala b/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala index c147dc483d..cf5b1fa2c4 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala @@ -221,7 +221,7 @@ abstract class CPSAnnotationChecker extends CPSUtils with Modes { } else if (retMode && !hasPlusMarker(tree.tpe) && annotsTree.isEmpty && annotsExpected.nonEmpty) { // add a marker annotation that will make tree.tpe behave as pt, subtyping wise // tree will look like having any possible annotation - + // note 1: we are only adding a plus marker if the method's result type is a cps type // (annotsExpected.nonEmpty == cpsParamAnnotation(pt).nonEmpty) // note 2: we are not adding the expected cps annotations, since they will be added @@ -234,7 +234,7 @@ abstract class CPSAnnotationChecker extends CPSUtils with Modes { /** Returns an adapted type for a return expression if the method's result type (pt) is a CPS type. * Otherwise, it returns the `default` type (`typedReturn` passes `NothingClass.tpe`). - * + * * A return expression in a method that has a CPS result type is an error unless the return * is in tail position. Therefore, we are making sure that only the types of return expressions * are adapted which will either be removed, or lead to an error. @@ -396,8 +396,10 @@ abstract class CPSAnnotationChecker extends CPSUtils with Modes { override def addAnnotations(tree: Tree, tpe: Type): Type = { import scala.util.control._ if (!cpsEnabled) { - if (Exception.failAsValue(classOf[MissingRequirementError])(false)(hasCpsParamTypes(tpe))) + val report = try hasCpsParamTypes(tpe) catch { case _: MissingRequirementError => false } + if (report) global.reporter.error(tree.pos, "this code must be compiled with the Scala continuations plugin enabled") + return tpe } |