@@ -15,8 +15,8 @@ import dotty.tools.dotc.core.StdNames.nme
15
15
import dotty .tools .dotc .core .Symbols .{ClassSymbol , NoSymbol , Symbol , defn , isDeprecated , requiredClass , requiredModule }
16
16
import dotty .tools .dotc .core .Types .*
17
17
import dotty .tools .dotc .report
18
- import dotty .tools .dotc .reporting .{Action , CodeAction , Diagnostic , UnusedSymbol , WConf }
19
- import dotty .tools .dotc .rewrites .Rewrites
18
+ import dotty .tools .dotc .reporting .{CodeAction , Diagnostic , UnusedSymbol }
19
+ import dotty .tools .dotc .rewrites .Rewrites . ActionPatch
20
20
import dotty .tools .dotc .transform .MegaPhase .MiniPhase
21
21
import dotty .tools .dotc .typer .{ImportInfo , Typer }
22
22
import dotty .tools .dotc .typer .Deriving .OriginalTypeClass
@@ -557,29 +557,15 @@ object CheckUnused:
557
557
558
558
def reportUnused ()(using Context ): Unit =
559
559
for (msg, pos, origin) <- warnings do
560
- if origin.isEmpty then report.warning(msg, pos)
561
- else report.warning(msg, pos, origin)
562
- // avoid rewrite if warning will be suppressed (would be nice if reporter knew how to apply actions)
563
- msg.actions.headOption match
564
- case Some (action) if ctx.run != null =>
565
- val dia =
566
- if origin.isEmpty then Diagnostic .Warning (msg, pos.sourcePos)
567
- else Diagnostic .LintWarning (msg, pos.sourcePos, origin)
568
- ctx.run.nn.suppressions.nowarnAction(dia) match
569
- case Action .Warning =>
570
- WConf .parsed.action(dia) match
571
- case Action .Error | Action .Warning =>
572
- Rewrites .applyAction(action)
573
- case _ =>
574
- case _ =>
575
- case _ =>
560
+ report.warning(msg, pos, origin)
576
561
577
562
type MessageInfo = (UnusedSymbol , SrcPos , String ) // string is origin or empty
578
563
579
564
def warnings (using Context ): Array [MessageInfo ] =
580
565
val actionable = ctx.settings.rewrite.value.nonEmpty
581
566
val warnings = ArrayBuilder .make[MessageInfo ]
582
- def warnAt (pos : SrcPos )(msg : UnusedSymbol , origin : String = " " ): Unit = warnings.addOne((msg, pos, origin))
567
+ def warnAt (pos : SrcPos )(msg : UnusedSymbol , origin : String = Diagnostic .OriginWarning .NoOrigin ): Unit =
568
+ warnings.addOne((msg, pos, origin))
583
569
val infos = refInfos
584
570
585
571
// non-local sym was target of assignment or has a sibling setter that was referenced
@@ -742,7 +728,6 @@ object CheckUnused:
742
728
743
729
def checkImports () =
744
730
import scala .jdk .CollectionConverters .given
745
- import Rewrites .ActionPatch
746
731
type ImpSel = (Import , ImportSelector )
747
732
def isUsed (sel : ImportSelector ): Boolean = infos.sels.containsKey(sel)
748
733
def warnImport (warnable : ImpSel , actions : List [CodeAction ] = Nil ): Unit =
0 commit comments