Skip to content

Commit 3f67e27

Browse files
committed
Move finishAggregation to UnusedData class in CheckUnused
1 parent 38c35bd commit 3f67e27

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

compiler/src/dotty/tools/dotc/transform/CheckUnused.scala

+14-14
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class CheckUnused private (phaseMode: CheckUnused.PhaseMode, suffix: String, _ke
6464

6565
override def transformUnit(tree: tpd.Tree)(using Context): tpd.Tree =
6666
unusedDataApply { ud =>
67-
finishAggregation(ud)
67+
ud.finishAggregation()
6868
if(phaseMode == PhaseMode.Report) then
6969
ud.unusedAggregate.foreach(reportUnused)
7070
}
@@ -253,17 +253,6 @@ class CheckUnused private (phaseMode: CheckUnused.PhaseMode, suffix: String, _ke
253253
private def traverseAnnotations(sym: Symbol)(using Context): Unit =
254254
sym.denot.annotations.foreach(annot => traverser.traverse(annot.tree))
255255

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-
267256

268257
/** Do the actual reporting given the result of the anaylsis */
269258
private def reportUnused(res: UnusedData.UnusedResult)(using Context): Unit =
@@ -371,6 +360,17 @@ object CheckUnused:
371360
execInNewScope
372361
popScope()
373362

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+
374374
/**
375375
* Register a found (used) symbol along with its name
376376
*
@@ -534,7 +534,7 @@ object CheckUnused:
534534
val pos = s.pos.sourcePos
535535
(pos.line, pos.column)
536536
}
537-
UnusedResult(warnings)
537+
UnusedResult(warnings.toSet)
538538
end getUnused
539539
//============================ HELPERS ====================================
540540

@@ -735,7 +735,7 @@ object CheckUnused:
735735
/** A container for the results of the used elements analysis */
736736
case class UnusedResult(warnings: Set[UnusedSymbol])
737737
object UnusedResult:
738-
val Empty = UnusedResult(Nil)
738+
val Empty = UnusedResult(Set.empty)
739739

740740
end CheckUnused
741741

0 commit comments

Comments
 (0)