@@ -11,7 +11,7 @@ import Scopes.newScope
1111import StdNames .nme
1212import Symbols .{ClassSymbol , NoSymbol , Symbol , defn , isDeprecated , requiredClass , requiredModule }
1313import Types .*
14- import reporting .{CodeAction , UnusedSymbol }
14+ import reporting .{Action , CodeAction , Diagnostic , UnusedSymbol , WConf }
1515import rewrites .Rewrites
1616
1717import MegaPhase .MiniPhase
@@ -557,7 +557,20 @@ object CheckUnused:
557557 for (msg, pos, origin) <- warnings do
558558 if origin.isEmpty then report.warning(msg, pos)
559559 else report.warning(msg, pos, origin)
560- msg.actions.headOption.foreach(Rewrites .applyAction)
560+ // avoid rewrite if warning will be suppressed (would be nice if reporter knew how to apply actions)
561+ msg.actions.headOption match
562+ case Some (action) if ctx.run != null =>
563+ val dia =
564+ if origin.isEmpty then Diagnostic .Warning (msg, pos.sourcePos)
565+ else Diagnostic .LintWarning (msg, pos.sourcePos, origin)
566+ ctx.run.nn.suppressions.nowarnAction(dia) match
567+ case Action .Warning =>
568+ WConf .parsed.action(dia) match
569+ case Action .Error | Action .Warning =>
570+ Rewrites .applyAction(action)
571+ case _ =>
572+ case _ =>
573+ case _ =>
561574
562575 type MessageInfo = (UnusedSymbol , SrcPos , String ) // string is origin or empty
563576
0 commit comments