summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/Global.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2012-04-12 18:56:20 -0700
committerMartin Odersky <odersky@gmail.com>2012-04-12 18:56:20 -0700
commita7a1e3a1959f26c9b44b40b328ef217b4ebdbaba (patch)
tree62e2b8b9149e9b62621591c1bfc1b6ffb0170c53 /src/compiler/scala/tools/nsc/Global.scala
parent6061a22fcd3480e18e60254ad06c8a46b2f1ce53 (diff)
downloadscala-a7a1e3a1959f26c9b44b40b328ef217b4ebdbaba.tar.gz
scala-a7a1e3a1959f26c9b44b40b328ef217b4ebdbaba.tar.bz2
scala-a7a1e3a1959f26c9b44b40b328ef217b4ebdbaba.zip
Various improvements to SIP 18 diagnostics. Made scala library and compiler feature clean.
Diffstat (limited to 'src/compiler/scala/tools/nsc/Global.scala')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index b7d7f5d16f..228496515b 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -938,6 +938,17 @@ class Global(var currentSettings: Settings, var reporter: NscReporter) extends S
inform("[running phase " + ph.name + " on " + currentRun.size + " compilation units]")
}
+ /** Collects for certain classes of warnings during this run. */
+ class ConditionalWarning(what: String, option: Settings#BooleanSetting) {
+ val warnings = new mutable.ListBuffer[(Position, String)]
+ def warn(pos: Position, msg: String) =
+ if (option.value) reporter.warning(pos, msg)
+ else warnings += ((pos, msg))
+ def summarize() =
+ if (option.isDefault && warnings.nonEmpty)
+ reporter.warning(NoPosition, "there were %d %s warnings; re-run with %s for details".format(warnings.size, what, option.name))
+ }
+
/** A Run is a single execution of the compiler on a sets of units
*/
class Run {
@@ -949,9 +960,12 @@ class Global(var currentSettings: Settings, var reporter: NscReporter) extends S
/** The currently compiled unit; set from GlobalPhase */
var currentUnit: CompilationUnit = NoCompilationUnit
- /** Counts for certain classes of warnings during this run. */
- var deprecationWarnings: List[(Position, String)] = Nil
- var uncheckedWarnings: List[(Position, String)] = Nil
+ val deprecationWarnings = new ConditionalWarning("deprecation", settings.deprecation)
+ val uncheckedWarnings = new ConditionalWarning("unchecked", settings.unchecked)
+ val featureWarnings = new ConditionalWarning("feature", settings.feature)
+ val allConditionalWarnings = List(deprecationWarnings, uncheckedWarnings, featureWarnings)
+
+ var reportedFeature = Set[Symbol]()
/** A flag whether macro expansions failed */
var macroExpansionFailed = false
@@ -1241,12 +1255,8 @@ class Global(var currentSettings: Settings, var reporter: NscReporter) extends S
}
}
else {
- def warn(count: Int, what: String, option: Settings#BooleanSetting) = (
- if (option.isDefault && count > 0)
- warning("there were %d %s warnings; re-run with %s for details".format(count, what, option.name))
- )
- warn(deprecationWarnings.size, "deprecation", settings.deprecation)
- warn(uncheckedWarnings.size, "unchecked", settings.unchecked)
+ allConditionalWarnings foreach (_.summarize)
+
if (macroExpansionFailed)
warning("some macros could not be expanded and code fell back to overridden methods;"+
"\nrecompiling with generated classfiles on the classpath might help.")