From befe39bea22430624767ef4f0bcd89ca4955b8f9 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 16 Feb 2022 19:26:39 +0100 Subject: [PATCH 1/2] Propagate unreported features when flushing a reporter Fixes #14500 --- compiler/src/dotty/tools/dotc/reporting/Reporter.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala index e159b5f83863..06df8da181dc 100644 --- a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala @@ -137,14 +137,17 @@ abstract class Reporter extends interfaces.ReporterResult { var unreportedWarnings: Map[String, Int] = Map.empty + def addUnreported(key: String, n: Int): Unit = + val count = unreportedWarnings.getOrElse(key, 0) + unreportedWarnings = unreportedWarnings.updated(key, count + 1) + /** Issue the diagnostic, ignoring `-Wconf` and `@nowarn` configurations, * but still honouring `-nowarn`, `-Werror`, and conditional warnings. */ def issueUnconfigured(dia: Diagnostic)(using Context): Unit = dia match case w: Warning if ctx.settings.silentWarnings.value => case w: ConditionalWarning if w.isSummarizedConditional => val key = w.enablingOption.name - val count = unreportedWarnings.getOrElse(key, 0) - unreportedWarnings = unreportedWarnings.updated(key, count + 1) + addUnreported(key, 1) case _ => // conditional warnings that are not enabled are not fatal val d = dia match @@ -241,6 +244,8 @@ abstract class Reporter extends interfaces.ReporterResult { def flush()(using Context): Unit = val msgs = removeBufferedMessages if msgs.nonEmpty then msgs.foreach(ctx.reporter.report) + for (key, count) <- unreportedWarnings do + ctx.reporter.addUnreported(key, count) /** If this reporter buffers messages, all buffered messages, otherwise Nil */ def pendingMessages(using Context): List[Diagnostic] = Nil From 5b9ede454480de12aacabebc44c66b2b1a733ca9 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 16 Feb 2022 21:06:33 +0100 Subject: [PATCH 2/2] Fix what -Xlint should have reported if it existed --- compiler/src/dotty/tools/dotc/reporting/Reporter.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala index 06df8da181dc..421d8f52b43a 100644 --- a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala @@ -139,7 +139,7 @@ abstract class Reporter extends interfaces.ReporterResult { def addUnreported(key: String, n: Int): Unit = val count = unreportedWarnings.getOrElse(key, 0) - unreportedWarnings = unreportedWarnings.updated(key, count + 1) + unreportedWarnings = unreportedWarnings.updated(key, count + n) /** Issue the diagnostic, ignoring `-Wconf` and `@nowarn` configurations, * but still honouring `-nowarn`, `-Werror`, and conditional warnings. */