diff options
author | Paul Phillips <paulp@improving.org> | 2013-01-25 14:15:45 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-01-25 16:28:44 -0800 |
commit | f3ac123f345b095580d1839e0f67ea07c6837946 (patch) | |
tree | 10322987043f41284f35da1d9a349e01179fcccb /src/compiler/scala/tools/nsc/typechecker/Typers.scala | |
parent | f01af109ae975461fe5a3120a69814521968fcce (diff) | |
parent | ac432bcde6b357194203d25df5f204ab8e426416 (diff) | |
download | scala-f3ac123f345b095580d1839e0f67ea07c6837946.tar.gz scala-f3ac123f345b095580d1839e0f67ea07c6837946.tar.bz2 scala-f3ac123f345b095580d1839e0f67ea07c6837946.zip |
Merge commit 'ac432bcde6' into pr/merge-2.10
* commit 'ac432bcde6':
Fix broken build.
SI-6434 Pretty print function types with by name arg as (=> A) => B
Removed class files.
SI-6994 Avoid spurious promiscuous catch warning
Addressing warnings.
SI-6439 Avoid spurious REPL warnings about companionship
use ArrayBuffer instead of Array to build Formulae
SI-6942 more efficient unreachability analysis
use Constant::isIntRange even if it's NIH
SI-6956 determine switchability by type, not tree
SI-5568 Comment improvements for getClass on primitive intersection.
SI-5568 Fixes verify error from getClass on refinement of value type
SI-6923 Context now buffers warnings as well as errors
Conflicts:
src/compiler/scala/tools/nsc/interpreter/IMain.scala
src/compiler/scala/tools/nsc/transform/Erasure.scala
src/compiler/scala/tools/nsc/typechecker/Contexts.scala
src/compiler/scala/tools/nsc/typechecker/Typers.scala
test/files/neg/t4851.check
Note:
This merge excludes b07228aebe7a as it breaks master.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 45f290d6c1..8d028857d4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -683,7 +683,15 @@ trait Typers extends Adaptations with Tags { if (context1.hasErrors) { stopStats() SilentTypeError(context1.errBuffer.head) - } else SilentResultValue(result) + } else { + // If we have a successful result, emit any warnings it created. + if (context1.hasWarnings) { + context1.flushAndReturnWarningsBuffer() foreach { + case (pos, msg) => unit.warning(pos, msg) + } + } + SilentResultValue(result) + } } else { assert(context.bufferErrors || isPastTyper, "silent mode is not available past typer") withSavedContext(context){ @@ -4919,13 +4927,15 @@ trait Typers extends Adaptations with Tags { var block1 = typed(tree.block, pt) var catches1 = typedCases(tree.catches, ThrowableClass.tpe, pt) - for (cdef <- catches1; if treeInfo catchesThrowable cdef) { - val name = (treeInfo assignedNameOfPattern cdef).decoded - context.warning(cdef.pat.pos, - s"""|This catches all Throwables, which often has undesirable consequences. - |If intentional, use `case $name : Throwable` to clear this warning.""".stripMargin - ) + for (cdef <- catches1 if !isPastTyper && 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.") + def unbound(t: Tree) = t.symbol == null || t.symbol == NoSymbol + cdef.pat match { + case Bind(name, i @ Ident(_)) if unbound(i) => warn(name) + case i @ Ident(name) if unbound(i) => warn(name) + case _ => } + } val finalizer1 = if (tree.finalizer.isEmpty) tree.finalizer |