summaryrefslogtreecommitdiff
path: root/src/continuations
diff options
context:
space:
mode:
authorphaller <hallerp@gmail.com>2012-08-09 14:50:30 +0200
committerphaller <hallerp@gmail.com>2012-08-09 14:50:30 +0200
commit8d020fab9758ced93eb18fa51c906b95ec104aed (patch)
tree2a5c394a11fb984a860c246a37a7b62cd824797b /src/continuations
parentb9c3a3b083833d2166b3d2ca2d1ccbca36b83c71 (diff)
downloadscala-8d020fab9758ced93eb18fa51c906b95ec104aed.tar.gz
scala-8d020fab9758ced93eb18fa51c906b95ec104aed.tar.bz2
scala-8d020fab9758ced93eb18fa51c906b95ec104aed.zip
Add missing cases in tail return transform
Disabled warnings that no longer apply because of tail returns. Add several test cases.
Diffstat (limited to 'src/continuations')
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala9
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala10
2 files changed, 11 insertions, 8 deletions
diff --git a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala b/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
index 46c644bcd6..90c961f195 100644
--- a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
+++ b/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
@@ -96,13 +96,8 @@ trait CPSUtils {
// anf transform
- def getExternalAnswerTypeAnn(tp: Type) = {
- cpsParamTypes(tp) orElse {
- if (hasPlusMarker(tp))
- global.warning("trying to instantiate type " + tp + " to unknown cps type")
- None
- }
- }
+ def getExternalAnswerTypeAnn(tp: Type) =
+ cpsParamTypes(tp) orElse None
def getAnswerTypeAnn(tp: Type): Option[(Type, Type)] =
cpsParamTypes(tp) filterNot (_ => hasPlusMarker(tp))
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala
index 1783264e5c..99838dfc25 100644
--- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala
+++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala
@@ -43,6 +43,12 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
case If(cond, r1 @ Return(thenExpr), r2 @ Return(elseExpr)) =>
treeCopy.If(tree, cond, transform(thenExpr), transform(elseExpr))
+ case If(cond, r1 @ Return(thenExpr), elseExpr) =>
+ treeCopy.If(tree, cond, transform(thenExpr), transform(elseExpr))
+
+ case If(cond, thenExpr, r2 @ Return(elseExpr)) =>
+ treeCopy.If(tree, cond, transform(thenExpr), transform(elseExpr))
+
case If(cond, thenExpr, elseExpr) =>
treeCopy.If(tree, cond, transform(thenExpr), transform(elseExpr))
@@ -440,7 +446,9 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
// all is well
if (hasPlusMarker(expr.tpe)) {
- unit.warning(tree.pos, "expression " + expr + " of type " + expr.tpe + " is not expected to have a cps type")
+ // the following warning no longer applies, since expr may have originated from a tail return expr
+ // note that it would be illegal to remove the plus marker (thus disabling required transformations)
+ //unit.warning(tree.pos, "expression " + expr + " of type " + expr.tpe + " is not expected to have a cps type")
expr modifyType removeAllCPSAnnotations
}