From 58abe39c9d8d75bc2c5ca27e1b8c0c33de9e6824 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Thu, 13 Jun 2013 14:32:49 -0400 Subject: SI-7433 Fix spurious warning about catching control throwable In the same vein as SI-6994, we have to be careful not to warn about synthetic code. In that case, the spurious warnings came because we warned in the typechecker, which was also called in erasure. In this case, we are issuing the warning in Uncurry, so we must be mindful of the pattern matchers translations of non-trivial catch patterns, which look like: case (ex8 @ _) => { val x5: Throwable = ex8; case11(){ if ({ case14(){ if (x5.$isInstanceOf[NullPointerException]()) matchEnd13(true) else case15() }; case15(){ if (x5.$isInstanceOf[RuntimeException]()) matchEnd13(true) else case16() }; case16(){ matchEnd13(false) }; matchEnd13(x: Boolean){ x } }) This commit detects that `ex8` is synthetic and disables the warning. --- src/reflect/scala/reflect/internal/TreeInfo.scala | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/reflect') 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, _) => -- cgit v1.2.3