From 58f6a1346093db2f407879246884d480ff8d7904 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 3 May 2012 14:36:14 -0700 Subject: 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. --- .../tools/selectivecps/SelectiveANFTransform.scala | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/continuations/plugin') 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 => -- cgit v1.2.3