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 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions compiler/src/dotty/tools/dotc/reporting/Reporter.scala
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 + 1)
dwijnand marked this conversation as resolved.
Show resolved Hide resolved

/** 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