diff options
author | phaller <hallerp@gmail.com> | 2012-08-09 17:23:47 +0200 |
---|---|---|
committer | phaller <hallerp@gmail.com> | 2012-08-09 17:23:47 +0200 |
commit | 47519b4eb6b4aec78e3c13e08811c7346c61acc4 (patch) | |
tree | a3e316e5549e9cb2c38ba13c3b8bc2e87a24b102 | |
parent | 8d020fab9758ced93eb18fa51c906b95ec104aed (diff) | |
download | scala-47519b4eb6b4aec78e3c13e08811c7346c61acc4.tar.gz scala-47519b4eb6b4aec78e3c13e08811c7346c61acc4.tar.bz2 scala-47519b4eb6b4aec78e3c13e08811c7346c61acc4.zip |
Revert "Add missing cases in tail return transform"
This reverts commit 8d020fab9758ced93eb18fa51c906b95ec104aed.
4 files changed, 8 insertions, 26 deletions
diff --git a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala b/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala index 90c961f195..46c644bcd6 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala @@ -96,8 +96,13 @@ trait CPSUtils { // anf transform - def getExternalAnswerTypeAnn(tp: Type) = - cpsParamTypes(tp) orElse None + def getExternalAnswerTypeAnn(tp: Type) = { + cpsParamTypes(tp) orElse { + if (hasPlusMarker(tp)) + global.warning("trying to instantiate type " + tp + " to unknown cps type") + 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 99838dfc25..1783264e5c 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala @@ -43,12 +43,6 @@ 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)) @@ -446,9 +440,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with // all is well if (hasPlusMarker(expr.tpe)) { - // 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") + unit.warning(tree.pos, "expression " + expr + " of type " + expr.tpe + " is not expected to have a cps type") expr modifyType removeAllCPSAnnotations } diff --git a/test/files/continuations-run/t5314.check b/test/files/continuations-run/t5314.check index 4b35d8e6d0..4951e7caae 100644 --- a/test/files/continuations-run/t5314.check +++ b/test/files/continuations-run/t5314.check @@ -1,7 +1,3 @@ -7 -7 -7 -8 8 hi 8 diff --git a/test/files/continuations-run/t5314.scala b/test/files/continuations-run/t5314.scala index d611016ce4..0bdea19824 100644 --- a/test/files/continuations-run/t5314.scala +++ b/test/files/continuations-run/t5314.scala @@ -29,17 +29,6 @@ object Test extends App { def nocps(x: Int): Int = { return x; x } - def foo2(x:Int): Int @cps[Int] = 7 - def bar2(x:Int): Int @cps[Int] = { foo2(x); return 7 } - def bar3(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else return foo2(x) } - def bar4(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else foo2(x) } - def bar5(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else 8 } - println(reset { bar2(10) }) - println(reset { bar3(10) }) - println(reset { bar4(10) }) - println(reset { bar5(10) }) - - /* original test case */ val repro = new ReturnRepro repro.caller repro.caller2 |