summaryrefslogtreecommitdiff
path: root/src/continuations
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-05-03 14:36:14 -0700
committerPaul Phillips <paulp@improving.org>2012-05-03 16:05:35 -0700
commit58f6a1346093db2f407879246884d480ff8d7904 (patch)
treed67237e70a8c206f27d0f9180264da0e446a05d0 /src/continuations
parent264cef8f9677c59395166da9be0af0bfe83abfa5 (diff)
downloadscala-58f6a1346093db2f407879246884d480ff8d7904.tar.gz
scala-58f6a1346093db2f407879246884d480ff8d7904.tar.bz2
scala-58f6a1346093db2f407879246884d480ff8d7904.zip
Fix for SI-3718.
And for a bunch of other tickets where we unleash a stack trace rather than printing a sensible error message. But SI-3718 is a continuations plugin crash, now a reasonable if somewhat vague error.
Diffstat (limited to 'src/continuations')
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala
index e9e9cf0fab..017c8d24fd 100644
--- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala
+++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala
@@ -110,8 +110,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
transExpr(body, None, ext)
}
- debuglog("anf result "+body1)
- debuglog("result is of type "+body1.tpe)
+ debuglog("anf result "+body1+"\nresult is of type "+body1.tpe)
treeCopy.Function(ff, transformValDefs(vparams), body1)
}
@@ -142,7 +141,6 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
transExpr(tree, None, None)
case _ =>
-
if (hasAnswerTypeAnn(tree.tpe)) {
if (!cpsAllowed)
unit.error(tree.pos, "cps code not allowed here / " + tree.getClass + " / " + tree)
@@ -357,7 +355,20 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
List(expr)
)
)
- return ((stms, call))
+ // This is today's sick/meaningless heuristic for spotting breakdown so
+ // we don't proceed until stack traces start draping themselves over everything.
+ // If there are wildcard types in the tree and B == Nothing, something went wrong.
+ // (I thought WildcardTypes would be enough, but nope. 'reset0 { 0 }' has them.)
+ //
+ // Code as simple as reset((_: String).length)
+ // will crash meaninglessly without this check. See SI-3718.
+ //
+ // TODO - obviously this should be done earlier, differently, or with
+ // a more skilled hand. Most likely, all three.
+ if ((b.typeSymbol eq NothingClass) && call.tpe.exists(_ eq WildcardType))
+ unit.error(tree.pos, "cannot cps-transform malformed (possibly in shift/reset placement) expression")
+ else
+ return ((stms, call))
}
catch {
case ex:TypeError =>