@@ -64,7 +64,7 @@ class CheckUnused private (phaseMode: CheckUnused.PhaseMode, suffix: String, _ke
64
64
65
65
override def transformUnit (tree : tpd.Tree )(using Context ): tpd.Tree =
66
66
unusedDataApply { ud =>
67
- finishAggregation(ud )
67
+ ud. finishAggregation()
68
68
if (phaseMode == PhaseMode .Report ) then
69
69
ud.unusedAggregate.foreach(reportUnused)
70
70
}
@@ -253,17 +253,6 @@ class CheckUnused private (phaseMode: CheckUnused.PhaseMode, suffix: String, _ke
253
253
private def traverseAnnotations (sym : Symbol )(using Context ): Unit =
254
254
sym.denot.annotations.foreach(annot => traverser.traverse(annot.tree))
255
255
256
- private def finishAggregation (data : UnusedData )(using Context ): Unit =
257
- val unusedInThisStage = data.getUnused
258
- data.unusedAggregate match {
259
- case None =>
260
- data.unusedAggregate = Some (unusedInThisStage)
261
- case Some (prevUnused) =>
262
- val intersection = unusedInThisStage.warnings.intersect(prevUnused.warnings)
263
- data.unusedAggregate = Some (UnusedResult (intersection))
264
- }
265
-
266
-
267
256
268
257
/** Do the actual reporting given the result of the anaylsis */
269
258
private def reportUnused (res : UnusedData .UnusedResult )(using Context ): Unit =
@@ -371,6 +360,17 @@ object CheckUnused:
371
360
execInNewScope
372
361
popScope()
373
362
363
+ def finishAggregation (using Context )(): Unit =
364
+ val unusedInThisStage = this .getUnused
365
+ this .unusedAggregate match {
366
+ case None =>
367
+ this .unusedAggregate = Some (unusedInThisStage)
368
+ case Some (prevUnused) =>
369
+ val intersection = unusedInThisStage.warnings.intersect(prevUnused.warnings)
370
+ this .unusedAggregate = Some (UnusedResult (intersection))
371
+ }
372
+
373
+
374
374
/**
375
375
* Register a found (used) symbol along with its name
376
376
*
@@ -534,7 +534,7 @@ object CheckUnused:
534
534
val pos = s.pos.sourcePos
535
535
(pos.line, pos.column)
536
536
}
537
- UnusedResult (warnings)
537
+ UnusedResult (warnings.toSet )
538
538
end getUnused
539
539
// ============================ HELPERS ====================================
540
540
@@ -735,7 +735,7 @@ object CheckUnused:
735
735
/** A container for the results of the used elements analysis */
736
736
case class UnusedResult (warnings : Set [UnusedSymbol ])
737
737
object UnusedResult :
738
- val Empty = UnusedResult (Nil )
738
+ val Empty = UnusedResult (Set .empty )
739
739
740
740
end CheckUnused
741
741
0 commit comments