diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-06-22 00:42:39 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-06-22 00:42:39 -0700 |
commit | cfc0e18dc55b33274c1275c192ade4a8d707d635 (patch) | |
tree | ed500a8374b7911fe3b6a7443784764fcd231022 /src | |
parent | ff016002738580a7de11977c91e0061dbcf270ad (diff) | |
parent | 7d8527b40a3bd6d93cf155b39ee50577751f3e91 (diff) | |
download | scala-cfc0e18dc55b33274c1275c192ade4a8d707d635.tar.gz scala-cfc0e18dc55b33274c1275c192ade4a8d707d635.tar.bz2 scala-cfc0e18dc55b33274c1275c192ade4a8d707d635.zip |
Merge pull request #752 from retronym/topic/warn-catch-all-4
SI-2807 Resurrect and refine the promiscuous catch warning.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index b12ca4f0b4..69d3fd7f47 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -4863,6 +4863,16 @@ trait Typers extends Modes with Adaptations with Tags { case Try(block, catches, finalizer) => var block1 = typed(block, pt) var catches1 = typedCases(catches, ThrowableClass.tpe, pt) + + for (cdef <- catches1 if cdef.guard.isEmpty) { + def warn(name: Name) = context.warning(cdef.pat.pos, s"This catches all Throwables. If this is really intended, use `case ${name.decoded} : Throwable` to clear this warning.") + cdef.pat match { + case Bind(name, Ident(_)) => warn(name) + case Ident(name) => warn(name) + case _ => + } + } + val finalizer1 = if (finalizer.isEmpty) finalizer else typed(finalizer, UnitClass.tpe) val (owntype, needAdapt) = ptOrLub(block1.tpe :: (catches1 map (_.tpe)), pt) |