@@ -17,15 +17,15 @@ import Phases.{unfusedPhases, Phase}
1717import sbt .interfaces .ProgressCallback
1818
1919import util .*
20- import reporting .{Suppression , Action , Profile , ActiveProfile , NoProfile }
21- import reporting .Diagnostic
22- import reporting .Diagnostic .Warning
20+ import reporting .{Suppression , Action , Profile , ActiveProfile , MessageFilter , NoProfile , WConf }
21+ import reporting .Diagnostic , Diagnostic .Warning
2322import rewrites .Rewrites
2423import profile .Profiler
2524import printing .XprintMode
2625import typer .ImplicitRunInfo
2726import config .Feature
2827import StdNames .nme
28+ import Spans .Span
2929
3030import java .io .{BufferedWriter , OutputStreamWriter }
3131import java .nio .charset .StandardCharsets
@@ -38,6 +38,7 @@ import Run.Progress
3838import scala .compiletime .uninitialized
3939import dotty .tools .dotc .transform .MegaPhase
4040import dotty .tools .dotc .transform .Pickler .AsyncTastyHolder
41+ import dotty .tools .dotc .util .chaining .*
4142import java .util .{Timer , TimerTask }
4243
4344/** A compiler run. Exports various methods to compile source files */
@@ -99,6 +100,26 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
99100 Action .Warning
100101 }
101102
103+ def registerNowarn (annotPos : SourcePosition , range : Span )(conf : String , pos : SrcPos )(using Context ): Unit =
104+ var verbose = false
105+ val filters = conf match
106+ case " " =>
107+ List (MessageFilter .Any )
108+ case " none" =>
109+ List (MessageFilter .None )
110+ case " verbose" | " v" =>
111+ verbose = true
112+ List (MessageFilter .Any )
113+ case conf =>
114+ WConf .parseFilters(conf).left.map: parseErrors =>
115+ report.warning(s " Invalid message filter \n ${parseErrors.mkString(" \n " )}" , pos)
116+ List (MessageFilter .None )
117+ .merge
118+ addSuppression :
119+ Suppression (annotPos, filters, range.start, range.end, verbose)
120+ .tap: sup =>
121+ if filters == List (MessageFilter .None ) then sup.markUsed() // invalid suppressions, don't report as unused
122+
102123 def addSuppression (sup : Suppression ): Unit =
103124 val suppressions = mySuppressions.getOrElseUpdate(sup.annotPos.source, ListBuffer .empty)
104125 if sup.start != sup.end && suppressions.forall(x => x.start != sup.start || x.end != sup.end) then
0 commit comments