Skip to content

Commit 26bc4ba

Browse files
committed
Report all warnings on Werror and fail at the end
1 parent e399c43 commit 26bc4ba

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

compiler/src/dotty/tools/dotc/Run.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,15 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
342342
val runCtx = ctx.fresh
343343
runCtx.setProfiler(Profiler())
344344
unfusedPhases.foreach(_.initContext(runCtx))
345+
<<<<<<< Updated upstream
345346
val fusedPhases = runCtx.base.allPhases
346347
runCtx.withProgressCallback: cb =>
347348
_progress = Progress(cb, this, fusedPhases.map(_.traversals).sum)
348349
runPhases(allPhases = fusedPhases)(using runCtx)
350+
=======
351+
runPhases(using runCtx)
352+
ctx.reporter.finalizeReporting()
353+
>>>>>>> Stashed changes
349354
if (!ctx.reporter.hasErrors)
350355
Rewrites.writeBack()
351356
suppressions.runFinished(hasErrors = ctx.reporter.hasErrors)

compiler/src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,14 @@ abstract class Reporter extends interfaces.ReporterResult {
172172
end issueUnconfigured
173173

174174
def issueIfNotSuppressed(dia: Diagnostic)(using Context): Unit =
175-
def toErrorIfFatal(dia: Diagnostic) = dia match
176-
case w: Warning if ctx.settings.silentWarnings.value => dia
177-
case w: ConditionalWarning if w.isSummarizedConditional => dia
178-
case w: Warning if ctx.settings.XfatalWarnings.value => w.toError
179-
case _ => dia
180175

181176
def go() =
182177
import Action._
183178
dia match
184179
case w: Warning => WConf.parsed.action(dia) match
185180
case Error => issueUnconfigured(w.toError)
186-
case Warning => issueUnconfigured(toErrorIfFatal(w))
187-
case Verbose => issueUnconfigured(toErrorIfFatal(w.setVerbose()))
181+
case Warning => issueUnconfigured(w)
182+
case Verbose => issueUnconfigured(w.setVerbose())
188183
case Info => issueUnconfigured(w.toInfo)
189184
case Silent =>
190185
case _ => issueUnconfigured(dia)
@@ -214,6 +209,10 @@ abstract class Reporter extends interfaces.ReporterResult {
214209
def incomplete(dia: Diagnostic)(using Context): Unit =
215210
incompleteHandler(dia, ctx)
216211

212+
def finalizeReporting()(using Context) =
213+
if (hasWarnings && ctx.settings.XfatalWarnings.value)
214+
report(new Error("No warnings can be incurred under -Werror.", NoSourcePosition))
215+
217216
/** Summary of warnings and errors */
218217
def summary: String = {
219218
val b = new mutable.ListBuffer[String]

0 commit comments

Comments
 (0)