diff options
author | Paul Phillips <paulp@improving.org> | 2013-04-03 09:08:51 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-04-03 09:08:51 -0700 |
commit | c726682bc91e33ab0372492ba682bcfb864731fc (patch) | |
tree | 288be8381089f580c3d691112e49f8950dea57a1 /src | |
parent | 1ad75702a6b7e349b79bc7672034d42ecf34d8a1 (diff) | |
parent | 530f4a544b95d77eff378d31122615eea195618a (diff) | |
download | scala-c726682bc91e33ab0372492ba682bcfb864731fc.tar.gz scala-c726682bc91e33ab0372492ba682bcfb864731fc.tar.bz2 scala-c726682bc91e33ab0372492ba682bcfb864731fc.zip |
Merge pull request #2337 from retronym/ticket/7110-2
SI-7110 Warn about naked try without catch/finally
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 36542cc9d9..0be7192471 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -5008,6 +5008,13 @@ trait Typers extends Adaptations with Tags { } def typedTry(tree: Try) = { + tree match { + case Try(_, Nil, EmptyTree) => + if (!isPastTyper) context.warning(tree.pos, + "A try without a catch or finally is equivalent to putting its body in a block; no exceptions are handled.") + case _ => + } + var block1 = typed(tree.block, pt) var catches1 = typedCases(tree.catches, ThrowableClass.tpe, pt) |