Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate unreported features when flushing a reporter #14503

Merged
merged 2 commits into from
Feb 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions compiler/src/dotty/tools/dotc/reporting/Reporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 + n)

/** 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
Expand Down Expand Up @@ -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
Expand Down