@@ -15,7 +15,7 @@ import dotty.tools.dotc.core.StdNames.nme
1515import dotty .tools .dotc .core .Symbols .{ClassSymbol , NoSymbol , Symbol , defn , isDeprecated , requiredClass , requiredModule }
1616import dotty .tools .dotc .core .Types .*
1717import dotty .tools .dotc .report
18- import dotty .tools .dotc .reporting .{CodeAction , UnusedSymbol }
18+ import dotty .tools .dotc .reporting .{Action , CodeAction , Diagnostic , UnusedSymbol , WConf }
1919import dotty .tools .dotc .rewrites .Rewrites
2020import dotty .tools .dotc .transform .MegaPhase .MiniPhase
2121import dotty .tools .dotc .typer .{ImportInfo , Typer }
@@ -551,7 +551,20 @@ object CheckUnused:
551551 for (msg, pos, origin) <- warnings do
552552 if origin.isEmpty then report.warning(msg, pos)
553553 else report.warning(msg, pos, origin)
554- msg.actions.headOption.foreach(Rewrites .applyAction)
554+ // avoid rewrite if warning will be suppressed (would be nice if reporter knew how to apply actions)
555+ msg.actions.headOption match
556+ case Some (action) if ctx.run != null =>
557+ val dia =
558+ if origin.isEmpty then Diagnostic .Warning (msg, pos.sourcePos)
559+ else Diagnostic .LintWarning (msg, pos.sourcePos, origin)
560+ ctx.run.nn.suppressions.nowarnAction(dia) match
561+ case Action .Warning =>
562+ WConf .parsed.action(dia) match
563+ case Action .Error | Action .Warning =>
564+ Rewrites .applyAction(action)
565+ case _ =>
566+ case _ =>
567+ case _ =>
555568
556569 type MessageInfo = (UnusedSymbol , SrcPos , String ) // string is origin or empty
557570
0 commit comments