Skip to content

Commit a51380c

Browse files
committed
Reporter: Add hasUnreportedMessages and clear unreported warnings in flush
1 parent f8e5203 commit a51380c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,23 @@ abstract class Reporter extends interfaces.ReporterResult {
244244
*/
245245
def hasUnreportedErrors: Boolean = false
246246

247+
/** Does this reporter contain any message that have yet to be reported by its outer reporter ?
248+
* This includes any warning stored in `unreportedWarnings` which need to be propagated to
249+
* get an accurate count of unreported warnings in the outer reporter.
250+
*/
251+
def hasUnreportedMessages(using Context): Boolean =
252+
pendingMessages.nonEmpty || unreportedWarnings.nonEmpty
253+
247254
/** If this reporter buffers messages, remove and return all buffered messages. */
248255
def removeBufferedMessages(using Context): List[Diagnostic] = Nil
249256

250-
/** Issue all error messages in this reporter to next outer one, or make sure they are written. */
257+
/** Issue all messages in this reporter to next outer one, or make sure they are written. */
251258
def flush()(using Context): Unit =
252259
val msgs = removeBufferedMessages
253260
if msgs.nonEmpty then msgs.foreach(ctx.reporter.report)
254261
for (key, count) <- unreportedWarnings do
255262
ctx.reporter.addUnreported(key, count)
263+
unreportedWarnings = Map.empty
256264

257265
/** If this reporter buffers messages, all buffered messages, otherwise Nil */
258266
def pendingMessages(using Context): List[Diagnostic] = Nil

0 commit comments

Comments
 (0)