summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/UnCurry.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-08-10 07:28:56 -0700
committerPaul Phillips <paulp@improving.org>2012-08-10 12:30:54 -0700
commit0aa77ffa7cf2a95d9d84d4bc5e635163a84ca931 (patch)
tree831815116e90f6d87dd42b3d379449c1db2aad80 /src/compiler/scala/tools/nsc/transform/UnCurry.scala
parentfbbbb2294680c0f57506f885971b148cae53c92d (diff)
downloadscala-0aa77ffa7cf2a95d9d84d4bc5e635163a84ca931.tar.gz
scala-0aa77ffa7cf2a95d9d84d4bc5e635163a84ca931.tar.bz2
scala-0aa77ffa7cf2a95d9d84d4bc5e635163a84ca931.zip
Warn about catching non-local returns.
Almost every time someone is shooting themself in the foot by catching a non-local return, it is apparent from the structure of the AST that they are doing so. Warn them.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/UnCurry.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 72dd8acad7..fc61997cd5 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -204,6 +204,12 @@ 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 _ =>
+ }
+
Block(List(keyDef), tryCatch)
}
}