Skip to content

Commit 329b639

Browse files
committed
Move isSuppressed check from Reporter to ConsoleReporter.
isSuppressed forces computation of the error message; should be called only when emitting the error. TODO: Generalize so that other emitting reporters inherit the behavior.
1 parent 215be8b commit 329b639

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/dotty/tools/dotc/reporting/ConsoleReporter.scala

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,17 @@ class ConsoleReporter(
4040
}
4141
}
4242

43-
override def doReport(d: Diagnostic)(implicit ctx: Context): Unit = d match {
44-
case d: Error =>
45-
printMessageAndPos(s"error: ${d.msg}", d.pos)
46-
if (ctx.settings.prompt.value) displayPrompt()
47-
case d: ConditionalWarning if !d.enablingOption.value =>
48-
case d: Warning =>
49-
printMessageAndPos(s"warning: ${d.msg}", d.pos)
50-
case _ =>
51-
printMessageAndPos(d.msg, d.pos)
52-
}
43+
override def doReport(d: Diagnostic)(implicit ctx: Context): Unit =
44+
if (!d.isSuppressed) d match {
45+
case d: Error =>
46+
printMessageAndPos(s"error: ${d.msg}", d.pos)
47+
if (ctx.settings.prompt.value) displayPrompt()
48+
case d: ConditionalWarning if !d.enablingOption.value =>
49+
case d: Warning =>
50+
printMessageAndPos(s"warning: ${d.msg}", d.pos)
51+
case _ =>
52+
printMessageAndPos(d.msg, d.pos)
53+
}
5354

5455
def displayPrompt(): Unit = {
5556
writer.print("\na)bort, s)tack, r)esume: ")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ abstract class Reporter {
216216

217217
def report(d: Diagnostic)(implicit ctx: Context): Unit = if (!isHidden(d)) {
218218
doReport(d)
219-
if (!d.isSuppressed) d match {
219+
d match {
220220
case d: ConditionalWarning if !d.enablingOption.value => unreportedWarnings(d.enablingOption.name) += 1
221221
case d: Warning => warningCount += 1
222222
case d: Error => errorCount += 1

0 commit comments

Comments
 (0)