Skip to content

Commit f448f73

Browse files
committed
Address review
1 parent 453e75c commit f448f73

File tree

1 file changed

+32
-39
lines changed

1 file changed

+32
-39
lines changed

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

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,56 +1206,49 @@ object Semantic:
12061206
cls == defn.AnyValClass ||
12071207
cls == defn.ObjectClass
12081208

1209-
// ----- Work list ---------------------------------------------------
1210-
class WorkList private[Semantic](tasks: List[ClassSymbol]):
1211-
/** Process the worklist until done */
1212-
final def work()(using Cache, Context): Unit =
1213-
for task <- tasks if isConcreteClass(task) do doTask(task)
1209+
// ----- API --------------------------------
12141210

1215-
/** Check an individual class
1216-
*
1217-
* This method should only be called from the work list scheduler.
1218-
*/
1219-
private def doTask(classSym: ClassSymbol)(using Cache, Context): Unit =
1220-
val thisRef = ThisRef(classSym)
1221-
val tpl = classSym.defTree.asInstanceOf[TypeDef].rhs.asInstanceOf[Template]
1211+
/** Check an individual class
1212+
*
1213+
* The class to be checked must be an instantiable concrete class.
1214+
*/
1215+
private def checkClass(classSym: ClassSymbol)(using Cache, Context): Unit =
1216+
val thisRef = ThisRef(classSym)
1217+
val tpl = classSym.defTree.asInstanceOf[TypeDef].rhs.asInstanceOf[Template]
12221218

1223-
@tailrec
1224-
def iterate(): Unit = {
1225-
given Promoted = Promoted.empty(classSym)
1226-
given Trace = Trace.empty.add(classSym.defTree)
1227-
given reporter: Reporter.BufferedReporter = new Reporter.BufferedReporter
1219+
@tailrec
1220+
def iterate(): Unit = {
1221+
given Promoted = Promoted.empty(classSym)
1222+
given Trace = Trace.empty.add(classSym.defTree)
1223+
given reporter: Reporter.BufferedReporter = new Reporter.BufferedReporter
12281224

1229-
thisRef.ensureFresh()
1225+
thisRef.ensureFresh()
12301226

1231-
// set up constructor parameters
1232-
for param <- tpl.constr.termParamss.flatten do
1233-
thisRef.updateField(param.symbol, Hot)
1227+
// set up constructor parameters
1228+
for param <- tpl.constr.termParamss.flatten do
1229+
thisRef.updateField(param.symbol, Hot)
12341230

1235-
log("checking " + classSym) { eval(tpl, thisRef, classSym) }
1236-
reporter.errors.foreach(_.issue)
1231+
log("checking " + classSym) { eval(tpl, thisRef, classSym) }
1232+
reporter.errors.foreach(_.issue)
12371233

1238-
if cache.hasChanged && reporter.errors.isEmpty then
1239-
// code to prepare cache and heap for next iteration
1240-
cache.prepareForNextIteration()
1241-
iterate()
1242-
else
1243-
cache.prepareForNextClass()
1244-
}
1245-
1246-
iterate()
1247-
end doTask
1248-
end WorkList
1234+
if cache.hasChanged && reporter.errors.isEmpty then
1235+
// code to prepare cache and heap for next iteration
1236+
cache.prepareForNextIteration()
1237+
iterate()
1238+
else
1239+
cache.prepareForNextClass()
1240+
}
12491241

1250-
// ----- API --------------------------------
1242+
iterate()
1243+
end checkClass
12511244

12521245
/**
12531246
* Check the specified concrete classes
12541247
*/
1255-
def checkClasses(concreteClasses: List[ClassSymbol])(using Context): Unit =
1256-
val workList = new WorkList(concreteClasses)
1257-
val cache = new Cache
1258-
workList.work()(using cache, ctx)
1248+
def checkClasses(classes: List[ClassSymbol])(using Context): Unit =
1249+
given Cache()
1250+
for classSym <- classes if isConcreteClass(classSym) do
1251+
checkClass(classSym)
12591252

12601253
// ----- Semantic definition --------------------------------
12611254

0 commit comments

Comments
 (0)