@@ -92,14 +92,21 @@ extends ImplicitRunInfo, ConstraintRunInfo, cc.CaptureRunInfo {
92
92
mySuspendedMessages.getOrElseUpdate(warning.pos.source, mutable.LinkedHashSet .empty) += warning
93
93
94
94
def nowarnAction (dia : Diagnostic ): Action .Warning .type | Action .Verbose .type | Action .Silent .type =
95
- mySuppressions.getOrElse(dia.pos.source, Nil ).find(_.matches(dia)) match {
96
- case Some (s) =>
95
+ mySuppressions.get(dia.pos.source) match
96
+ case Some (suppressions) =>
97
+ val matching = suppressions.iterator.filter(_.matches(dia))
98
+ if matching.hasNext then
99
+ val s = matching.next()
100
+ for other <- matching do
101
+ if ! other.used then
102
+ other.markSuperseded() // superseded unless marked used later
97
103
s.markUsed()
98
- if ( s.verbose) Action .Verbose
104
+ if s.verbose then Action .Verbose
99
105
else Action .Silent
100
- case _ =>
106
+ else
101
107
Action .Warning
102
- }
108
+ case none =>
109
+ Action .Warning
103
110
104
111
def registerNowarn (annotPos : SourcePosition , range : Span )(conf : String , pos : SrcPos )(using Context ): Unit =
105
112
var verbose = false
@@ -132,7 +139,8 @@ extends ImplicitRunInfo, ConstraintRunInfo, cc.CaptureRunInfo {
132
139
mySuspendedMessages.remove(source).foreach(_.foreach(ctx.reporter.issueIfNotSuppressed))
133
140
}
134
141
135
- def runFinished (hasErrors : Boolean ): Unit =
142
+ def runFinished ()(using Context ): Unit =
143
+ val hasErrors = ctx.reporter.hasErrors
136
144
// report suspended messages (in case the run finished before typer)
137
145
mySuspendedMessages.keysIterator.toList.foreach(reportSuspendedMessages)
138
146
// report unused nowarns only if all all phases are done
@@ -147,7 +155,9 @@ extends ImplicitRunInfo, ConstraintRunInfo, cc.CaptureRunInfo {
147
155
&& ! suppressions.exists(s => s.ne(sup) && s.used && s.annotPos == sup.annotPos) // duplicate
148
156
&& sup.filters != List (MessageFilter .None ) // invalid suppression, don't report as unused
149
157
then
150
- report.warning(" @nowarn annotation does not suppress any warnings" , sup.annotPos)
158
+ val more = if sup.superseded then " but matches a diagnostic" else " "
159
+ report.warning(" @nowarn annotation does not suppress any warnings" + more, sup.annotPos)
160
+ end suppressions
151
161
152
162
/** The compilation units currently being compiled, this may return different
153
163
* results over time.
@@ -413,7 +423,7 @@ extends ImplicitRunInfo, ConstraintRunInfo, cc.CaptureRunInfo {
413
423
ctx.reporter.finalizeReporting()
414
424
if (! ctx.reporter.hasErrors)
415
425
Rewrites .writeBack()
416
- suppressions.runFinished(hasErrors = ctx.reporter.hasErrors )
426
+ suppressions.runFinished()
417
427
while (finalizeActions.nonEmpty && canProgress()) {
418
428
val action = finalizeActions.remove(0 )
419
429
action()
0 commit comments