summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2013-06-23 23:13:01 -0700
committerGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2013-06-23 23:13:01 -0700
commitb29e515205581d58d239464daadf37f0f1537519 (patch)
treed88c0547a87ef8f03bd06ff557f14065581a93c9 /src
parent693a36d7692628c5765276a2d7390aae75eed5e5 (diff)
parent58abe39c9d8d75bc2c5ca27e1b8c0c33de9e6824 (diff)
downloadscala-b29e515205581d58d239464daadf37f0f1537519.tar.gz
scala-b29e515205581d58d239464daadf37f0f1537519.tar.bz2
scala-b29e515205581d58d239464daadf37f0f1537519.zip
Merge pull request #2653 from retronym/ticket/7433
SI-7433 Fix spurious warning about catching control throwable
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala8
-rw-r--r--src/reflect/scala/reflect/internal/TreeInfo.scala6
2 files changed, 13 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 64f4e579e1..e2ce2743f7 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -187,8 +187,14 @@ abstract class UnCurry extends InfoTransform
val keyDef = ValDef(key, New(ObjectTpe))
val tryCatch = Try(body, pat -> rhs)
- for (Try(t, catches, _) <- body ; cdef <- catches ; if treeInfo catchesThrowable cdef)
+ import treeInfo.{catchesThrowable, isSyntheticCase}
+ for {
+ Try(t, catches, _) <- body
+ cdef <- catches
+ if catchesThrowable(cdef) && !isSyntheticCase(cdef)
+ } {
unit.warning(body.pos, "catch block may intercept non-local return from " + meth)
+ }
Block(List(keyDef), tryCatch)
}
diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala
index 3a8d3fd460..30ec555bc5 100644
--- a/src/reflect/scala/reflect/internal/TreeInfo.scala
+++ b/src/reflect/scala/reflect/internal/TreeInfo.scala
@@ -553,6 +553,12 @@ abstract class TreeInfo {
})
)
+ /** Is this CaseDef synthetically generated, e.g. by `MatchTranslation.translateTry`? */
+ def isSyntheticCase(cdef: CaseDef) = cdef.pat.exists {
+ case dt: DefTree => dt.symbol.isSynthetic
+ case _ => false
+ }
+
/** Is this pattern node a catch-all or type-test pattern? */
def isCatchCase(cdef: CaseDef) = cdef match {
case CaseDef(Typed(Ident(nme.WILDCARD), tpt), EmptyTree, _) =>