@@ -30,7 +30,7 @@ import StdNames.nme
30
30
import java .io .{BufferedWriter , OutputStreamWriter }
31
31
import java .nio .charset .StandardCharsets
32
32
33
- import scala .collection .mutable
33
+ import scala .collection .mutable , mutable . ListBuffer
34
34
import scala .util .control .NonFatal
35
35
import scala .io .Codec
36
36
@@ -69,7 +69,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
69
69
private var myFiles : Set [AbstractFile ] = uninitialized
70
70
71
71
// `@nowarn` annotations by source file, populated during typer
72
- private val mySuppressions : mutable.LinkedHashMap [SourceFile , mutable. ListBuffer [Suppression ]] = mutable.LinkedHashMap .empty
72
+ private val mySuppressions : mutable.LinkedHashMap [SourceFile , ListBuffer [Suppression ]] = mutable.LinkedHashMap .empty
73
73
// source files whose `@nowarn` annotations are processed
74
74
private val mySuppressionsComplete : mutable.Set [SourceFile ] = mutable.Set .empty
75
75
// warnings issued before a source file's `@nowarn` annotations are processed, suspended so that `@nowarn` can filter them
@@ -99,8 +99,9 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
99
99
}
100
100
101
101
def addSuppression (sup : Suppression ): Unit =
102
- val source = sup.annotPos.source
103
- mySuppressions.getOrElseUpdate(source, mutable.ListBuffer .empty) += sup
102
+ val suppressions = mySuppressions.getOrElseUpdate(sup.annotPos.source, ListBuffer .empty)
103
+ if ! suppressions.exists(_.annotPos == sup.annotPos) then
104
+ suppressions += sup
104
105
105
106
def reportSuspendedMessages (source : SourceFile )(using Context ): Unit = {
106
107
// sort suppressions. they are not added in any particular order because of lazy type completion
@@ -115,11 +116,12 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
115
116
mySuspendedMessages.keysIterator.toList.foreach(reportSuspendedMessages)
116
117
// report unused nowarns only if all all phases are done
117
118
if ! hasErrors && ctx.settings.WunusedHas .nowarn then
118
- for {
119
+ for
119
120
source <- mySuppressions.keysIterator.toList
120
121
sups <- mySuppressions.remove(source)
121
122
sup <- sups.reverse
122
- } if (! sup.used)
123
+ if ! sup.used
124
+ do
123
125
report.warning(" @nowarn annotation does not suppress any warnings" , sup.annotPos)
124
126
125
127
/** The compilation units currently being compiled, this may return different
@@ -130,7 +132,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
130
132
private def units_= (us : List [CompilationUnit ]): Unit =
131
133
myUnits = us
132
134
133
- var suspendedUnits : mutable. ListBuffer [CompilationUnit ] = mutable. ListBuffer ()
135
+ var suspendedUnits : ListBuffer [CompilationUnit ] = ListBuffer .empty
134
136
var suspendedHints : mutable.Map [CompilationUnit , (String , Boolean )] = mutable.HashMap ()
135
137
136
138
/** Were any units suspended in the typer phase? if so then pipeline tasty can not complete. */
@@ -172,7 +174,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
172
174
val staticRefs = util.EqHashMap [Name , Denotation ](initialCapacity = 1024 )
173
175
174
176
/** Actions that need to be performed at the end of the current compilation run */
175
- private var finalizeActions = mutable. ListBuffer [() => Unit ]()
177
+ private var finalizeActions = ListBuffer .empty [() => Unit ]
176
178
177
179
private var _progress : Progress | Null = null // Set if progress reporting is enabled
178
180
0 commit comments