Skip to content

Commit 2c262d9

Browse files
committed
Code refactoring
1 parent f2f72bf commit 2c262d9

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

compiler/src/dotty/tools/dotc/transform/init/Checker.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@ class Checker extends Phase {
3131

3232
override def runOn(units: List[CompilationUnit])(using Context): List[CompilationUnit] =
3333
val checkCtx = ctx.fresh.setPhase(this.start)
34-
Semantic.withInitialState {
34+
Semantic.checkTasks(using checkCtx) {
3535
val traverser = new InitTreeTraverser()
3636
units.foreach { unit => traverser.traverse(unit.tpdTree) }
37-
given Context = checkCtx
38-
Semantic.check()
39-
super.runOn(units)
4037
}
38+
units
4139

4240
def run(using Context): Unit = {
4341
// ignore, we already called `Semantic.check()` in `runOn`

compiler/src/dotty/tools/dotc/transform/init/Semantic.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,6 @@ object Semantic:
11311131
*
11321132
*/
11331133
def tryPromote(msg: String): Contextual[List[Error]] = log("promote " + warm.show + ", promoted = " + promoted, printer) {
1134-
val classRef = warm.klass.appliedRef
11351134
val obj = warm.objekt
11361135

11371136
def doPromote(klass: ClassSymbol, subClass: ClassSymbol, subClassSegmentHot: Boolean)(using Reporter): Unit =
@@ -1268,16 +1267,17 @@ object Semantic:
12681267
*/
12691268
def check()(using Cache, WorkList, Context) = workList.work()
12701269

1271-
/** Perform actions with initial checking state.
1270+
/** Check the specified tasks
12721271
*
1273-
* Semantic.withInitialState {
1272+
* Semantic.checkTasks {
12741273
* Semantic.addTask(...)
1275-
* ...
1276-
* Semantic.check()
12771274
* }
12781275
*/
1279-
def withInitialState[T](work: (Cache, WorkList) ?=> T): T =
1280-
work(using new Cache, new WorkList)
1276+
def checkTasks(using Context)(taskBuilder: WorkList ?=> Unit): Unit =
1277+
val workList = new WorkList
1278+
val cache = new Cache
1279+
taskBuilder(using workList)
1280+
Semantic.check()(using cache, workList, ctx)
12811281

12821282
// ----- Semantic definition --------------------------------
12831283

0 commit comments

Comments
 (0)