@@ -16,8 +16,8 @@ import dotty.tools.dotc.core.StdNames.nme
1616import dotty .tools .dotc .core .Symbols .{ClassSymbol , NoSymbol , Symbol , defn , isDeprecated , requiredClass , requiredModule }
1717import dotty .tools .dotc .core .Types .*
1818import dotty .tools .dotc .report
19- import dotty .tools .dotc .reporting .{CodeAction , UnusedSymbol }
20- import dotty .tools .dotc .rewrites .Rewrites
19+ import dotty .tools .dotc .reporting .{CodeAction , Diagnostic , UnusedSymbol }
20+ import dotty .tools .dotc .rewrites .Rewrites . ActionPatch
2121import dotty .tools .dotc .transform .MegaPhase .MiniPhase
2222import dotty .tools .dotc .typer .{ImportInfo , Typer }
2323import dotty .tools .dotc .typer .Deriving .OriginalTypeClass
@@ -529,7 +529,20 @@ object CheckUnused:
529529 for (msg, pos, origin) <- warnings do
530530 if origin.isEmpty then report.warning(msg, pos)
531531 else report.warning(msg, pos, origin)
532- msg.actions.headOption.foreach(Rewrites .applyAction)
532+ // avoid rewrite if warning will be suppressed (would be nice if reporter knew how to apply actions)
533+ msg.actions.headOption match
534+ case Some (action) if ctx.run != null =>
535+ val dia =
536+ if origin.isEmpty then Diagnostic .Warning (msg, pos.sourcePos)
537+ else Diagnostic .LintWarning (msg, pos.sourcePos, origin)
538+ ctx.run.nn.suppressions.nowarnAction(dia) match
539+ case Action .Warning =>
540+ WConf .parsed.action(dia) match
541+ case Action .Error | Action .Warning =>
542+ Rewrites .applyAction(action)
543+ case _ =>
544+ case _ =>
545+ case _ =>
533546
534547 type MessageInfo = (UnusedSymbol , SrcPos , String ) // string is origin or empty
535548
0 commit comments