summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/UnCurry.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-10-02 10:37:13 -0700
committerPaul Phillips <paulp@improving.org>2012-10-04 16:08:31 -0700
commitd7354838948be58b8045e1218a9c757d9b90df76 (patch)
treef034b77a430cb98fc6f5add55e645be28b0cf21e /src/compiler/scala/tools/nsc/transform/UnCurry.scala
parent1f99df2c66cb1933dd4db74aa872497a4e26975b (diff)
downloadscala-d7354838948be58b8045e1218a9c757d9b90df76.tar.gz
scala-d7354838948be58b8045e1218a9c757d9b90df76.tar.bz2
scala-d7354838948be58b8045e1218a9c757d9b90df76.zip
Fix for spurious warning.
Eliminates spurious "catch block may intercept non-local return" seen in recent builds of master. Unified some catch logic in TreeInfo, and removed some which never worked.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/UnCurry.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index f68cbfc141..ea93ad1bd4 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -205,11 +205,8 @@ abstract class UnCurry extends InfoTransform
val keyDef = ValDef(key, New(ObjectClass.tpe))
val tryCatch = Try(body, pat -> rhs)
- body foreach {
- case Try(t, catches, _) if catches exists treeInfo.catchesThrowable =>
- unit.warning(body.pos, "catch block may intercept non-local return from " + meth)
- case _ =>
- }
+ for (Try(t, catches, _) <- body ; cdef <- catches ; if treeInfo catchesThrowable cdef)
+ unit.warning(body.pos, "catch block may intercept non-local return from " + meth)
Block(List(keyDef), tryCatch)
}
@@ -691,16 +688,16 @@ abstract class UnCurry extends InfoTransform
else
tree
}
-
+
def isThrowable(pat: Tree): Boolean = pat match {
- case Typed(Ident(nme.WILDCARD), tpt) =>
+ case Typed(Ident(nme.WILDCARD), tpt) =>
tpt.tpe =:= ThrowableClass.tpe
- case Bind(_, pat) =>
+ case Bind(_, pat) =>
isThrowable(pat)
case _ =>
false
}
-
+
def isDefaultCatch(cdef: CaseDef) = isThrowable(cdef.pat) && cdef.guard.isEmpty
def postTransformTry(tree: Try) = {
@@ -764,10 +761,10 @@ abstract class UnCurry extends InfoTransform
case tree: Try =>
postTransformTry(tree)
-
+
case Apply(Apply(fn, args), args1) =>
treeCopy.Apply(tree, fn, args ::: args1)
-
+
case Ident(name) =>
assert(name != tpnme.WILDCARD_STAR, tree)
applyUnary()