diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-07-09 18:14:06 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-07-17 15:49:20 +0200 |
commit | dda3f241e7c47d13710be6a7e1ea9d5ef69709b2 (patch) | |
tree | 04ae4224507adb9d6aa77629a3d419c73191a586 | |
parent | b8503f6cf937b739341a6a387800c4542e81ae77 (diff) | |
download | scala-dda3f241e7c47d13710be6a7e1ea9d5ef69709b2.tar.gz scala-dda3f241e7c47d13710be6a7e1ea9d5ef69709b2.tar.bz2 scala-dda3f241e7c47d13710be6a7e1ea9d5ef69709b2.zip |
Rely less on intricacies of `contextMode`-based reporting.
- when warning must not be suppressed, use `reporter.warning`
- don't (implicitly) rely on `reporter.warning` being silent after typer
--> don't do pure expression check after typer
3 files changed, 6 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 6951ff2f0b..1010ceafe3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -640,8 +640,8 @@ trait Contexts { self: Analyzer => } /** Issue/throw the given error message according to the current mode for error reporting. */ - def warning(pos: Position, msg: String, force: Boolean = false) { - if (reportErrors || force) reporter.warning(pos, msg) + def warning(pos: Position, msg: String) { + if (reportErrors) reporter.warning(pos, msg) else if (bufferErrors) reportBuffer += (pos -> msg) } diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index 7440f69e93..fbea69db5a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -572,11 +572,11 @@ trait TypeDiagnostics { } else f } def apply(tree: Tree): Tree = { - // Error suppression will squash some of these warnings unless we circumvent it. + // Error suppression (in context.warning) would squash some of these warnings. // It is presumed if you are using a -Y option you would really like to hear - // the warnings you've requested. + // the warnings you've requested; thus, use reporter.warning. if (settings.warnDeadCode && context.unit.exists && treeOK(tree) && exprOK) - context.warning(tree.pos, "dead code following this construct", force = true) + reporter.warning(tree.pos, "dead code following this construct") tree } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index e0af229d3a..ce031e9cd7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2990,7 +2990,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper ConstructorsOrderError(stat) } - if (treeInfo.isPureExprForWarningPurposes(result)) context.warning(stat.pos, + if (!isPastTyper && treeInfo.isPureExprForWarningPurposes(result)) context.warning(stat.pos, "a pure expression does nothing in statement position; " + "you may be omitting necessary parentheses" ) |