@@ -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
@@ -549,29 +549,15 @@ object CheckUnused:
549
549
550
550
def reportUnused ()(using Context ): Unit =
551
551
for (msg, pos, origin) <- warnings do
552
- if origin.isEmpty then report.warning(msg, pos)
553
- else report.warning(msg, pos, origin)
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 _ =>
552
+ report.warning(msg, pos, origin)
568
553
569
554
type MessageInfo = (UnusedSymbol , SrcPos , String ) // string is origin or empty
570
555
571
556
def warnings (using Context ): Array [MessageInfo ] =
572
557
val actionable = ctx.settings.rewrite.value.nonEmpty
573
558
val warnings = ArrayBuilder .make[MessageInfo ]
574
- def warnAt (pos : SrcPos )(msg : UnusedSymbol , origin : String = " " ): Unit = warnings.addOne((msg, pos, origin))
559
+ def warnAt (pos : SrcPos )(msg : UnusedSymbol , origin : String = Diagnostic .OriginWarning .NoOrigin ): Unit =
560
+ warnings.addOne((msg, pos, origin))
575
561
val infos = refInfos
576
562
577
563
// non-local sym was target of assignment or has a sibling setter that was referenced
@@ -734,7 +720,6 @@ object CheckUnused:
734
720
735
721
def checkImports () =
736
722
import scala .jdk .CollectionConverters .given
737
- import Rewrites .ActionPatch
738
723
type ImpSel = (Import , ImportSelector )
739
724
def isUsed (sel : ImportSelector ): Boolean = infos.sels.containsKey(sel)
740
725
def warnImport (warnable : ImpSel , actions : List [CodeAction ] = Nil ): Unit =
0 commit comments