@@ -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
@@ -68,7 +68,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
68
68
private var myFiles : Set [AbstractFile ] = _
69
69
70
70
// `@nowarn` annotations by source file, populated during typer
71
- private val mySuppressions : mutable.LinkedHashMap [SourceFile , mutable. ListBuffer [Suppression ]] = mutable.LinkedHashMap .empty
71
+ private val mySuppressions : mutable.LinkedHashMap [SourceFile , ListBuffer [Suppression ]] = mutable.LinkedHashMap .empty
72
72
// source files whose `@nowarn` annotations are processed
73
73
private val mySuppressionsComplete : mutable.Set [SourceFile ] = mutable.Set .empty
74
74
// warnings issued before a source file's `@nowarn` annotations are processed, suspended so that `@nowarn` can filter them
@@ -98,8 +98,9 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
98
98
}
99
99
100
100
def addSuppression (sup : Suppression ): Unit =
101
- val source = sup.annotPos.source
102
- mySuppressions.getOrElseUpdate(source, mutable.ListBuffer .empty) += sup
101
+ val suppressions = mySuppressions.getOrElseUpdate(sup.annotPos.source, ListBuffer .empty)
102
+ if sup.start != sup.end && suppressions.forall(x => x.start != sup.start || x.end != sup.end) then
103
+ suppressions += sup
103
104
104
105
def reportSuspendedMessages (source : SourceFile )(using Context ): Unit = {
105
106
// sort suppressions. they are not added in any particular order because of lazy type completion
@@ -114,11 +115,12 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
114
115
mySuspendedMessages.keysIterator.toList.foreach(reportSuspendedMessages)
115
116
// report unused nowarns only if all all phases are done
116
117
if ! hasErrors && ctx.settings.WunusedHas .nowarn then
117
- for {
118
+ for
118
119
source <- mySuppressions.keysIterator.toList
119
120
sups <- mySuppressions.remove(source)
120
121
sup <- sups.reverse
121
- } if (! sup.used)
122
+ if ! sup.used
123
+ do
122
124
report.warning(" @nowarn annotation does not suppress any warnings" , sup.annotPos)
123
125
124
126
/** The compilation units currently being compiled, this may return different
@@ -167,7 +169,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
167
169
val staticRefs = util.EqHashMap [Name , Denotation ](initialCapacity = 1024 )
168
170
169
171
/** Actions that need to be performed at the end of the current compilation run */
170
- private var finalizeActions = mutable. ListBuffer [() => Unit ]()
172
+ private var finalizeActions = ListBuffer .empty [() => Unit ]
171
173
172
174
private var _progress : Progress | Null = null // Set if progress reporting is enabled
173
175
0 commit comments