Skip to content

Commit e369d90

Browse files
szymon-rdKordyjan
authored andcommitted
Move finishAggregation to UnusedData class in CheckUnused
1 parent 644fee2 commit e369d90

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
*
@@ -536,7 +536,7 @@ object CheckUnused:
536536
val pos = s.pos.sourcePos
537537
(pos.line, pos.column)
538538
}
539-
UnusedResult(warnings)
539+
UnusedResult(warnings.toSet)
540540
end getUnused
541541
//============================ HELPERS ====================================
542542

@@ -739,7 +739,7 @@ object CheckUnused:
739739
/** A container for the results of the used elements analysis */
740740
case class UnusedResult(warnings: Set[UnusedSymbol])
741741
object UnusedResult:
742-
val Empty = UnusedResult(Nil)
742+
val Empty = UnusedResult(Set.empty)
743743

744744
end CheckUnused
745745

0 commit comments

Comments
 (0)