@@ -1131,11 +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
1135- val hasInnerClass = classRef.memberClasses.filter(_.symbol.hasSource).nonEmpty
1136- if hasInnerClass then
1137- return PromoteError (msg + " Promotion cancelled as the value contains inner classes." , trace.toVector) :: Nil
1138-
11391134 val obj = warm.objekt
11401135
11411136 def doPromote (klass : ClassSymbol , subClass : ClassSymbol , subClassSegmentHot : Boolean )(using Reporter ): Unit =
@@ -1148,7 +1143,9 @@ object Semantic:
11481143 params.forall(param => obj.field(param).isHot)
11491144 }
11501145
1151- // check invariant: subClassSegmentHot => isHotSegment
1146+ // Check invariant: subClassSegmentHot ==> isHotSegment
1147+ //
1148+ // This invariant holds because of the Scala/Java/JVM restriction that we cannot use `this` in super constructor calls.
11521149 if subClassSegmentHot && ! isHotSegment then
11531150 report.error(" [Internal error] Expect current segment to hot in promotion, current klass = " + klass.show +
11541151 " , subclass = " + subClass.show + Trace .show, Trace .position)
@@ -1158,7 +1155,10 @@ object Semantic:
11581155 // those methods are checked as part of the check for the class where they are defined.
11591156 if ! isHotSegment then
11601157 for member <- klass.info.decls do
1161- if ! member.isType && ! member.isConstructor && member.hasSource && ! member.is(Flags .Deferred ) then
1158+ if member.isClass then
1159+ val error = PromoteError (" Promotion cancelled as the value contains inner " + member.show + " ." , Vector .empty)
1160+ reporter.report(error)
1161+ else if ! member.isType && ! member.isConstructor && ! member.is(Flags .Deferred ) then
11621162 given Trace = Trace .empty
11631163 if member.is(Flags .Method , butNot = Flags .Accessor ) then
11641164 val args = member.info.paramInfoss.flatten.map(_ => ArgInfo (Hot , Trace .empty))
@@ -1261,22 +1261,17 @@ object Semantic:
12611261 /** Add a checking task to the work list */
12621262 def addTask (thisRef : ThisRef )(using WorkList ) = workList.addTask(Task (thisRef))
12631263
1264- /** Perform check on the work list until it becomes empty
1265- *
1266- * Should only be called once from the checker.
1267- */
1268- def check ()(using Cache , WorkList , Context ) = workList.work()
1269-
1270- /** Perform actions with initial checking state.
1264+ /** Check the specified tasks
12711265 *
1272- * Semantic.withInitialState {
1266+ * Semantic.checkTasks {
12731267 * Semantic.addTask(...)
1274- * ...
1275- * Semantic.check()
12761268 * }
12771269 */
1278- def withInitialState [T ](work : (Cache , WorkList ) ?=> T ): T =
1279- work(using new Cache , new WorkList )
1270+ def checkTasks (using Context )(taskBuilder : WorkList ?=> Unit ): Unit =
1271+ val workList = new WorkList
1272+ val cache = new Cache
1273+ taskBuilder(using workList)
1274+ workList.work()(using cache, ctx)
12801275
12811276// ----- Semantic definition --------------------------------
12821277
0 commit comments