@@ -285,6 +285,40 @@ object Checking {
285
285
case _ => false
286
286
}
287
287
288
+ // / Check the Promotion of a Warm object, according to "Rule 2":
289
+ //
290
+ // Rule 2: Promote(pot)
291
+ //
292
+ // for all concrete methods `m` of D
293
+ // pot.m!, Promote(pot.m)
294
+ //
295
+ // for all concrete fields `f` of D
296
+ // Promote(pot.f)
297
+ //
298
+ // for all inner classes `F` of D
299
+ // Warm[F, pot].init!, Promote(Warm[F, pot])
300
+ private def checkPromoteWarm (warm : Warm , eff : Effect )(using state : State ): Errors =
301
+ val Warm (cls, outer) = warm
302
+ // Errors.empty
303
+ val classRef = cls.info.asInstanceOf [ClassInfo ].appliedRef
304
+ // All members of class must be promotable.
305
+ val memberErrs = classRef.allMembers.flatMap { denot =>
306
+ val sym = denot.symbol
307
+ val summary = warm.toPots.select(sym, warm.source, true )
308
+ (summary.effs ++ summary.pots.map(Promote (_)(warm.source)).toList)
309
+ }.flatMap(check(_))
310
+
311
+ // All inner classes of classRef must be promotable.
312
+ // TODO: Implement this
313
+ val innerClassesErrs = Errors .empty
314
+
315
+ val errs = memberErrs ++ innerClassesErrs
316
+ if errs.isEmpty then {
317
+ Errors .empty
318
+ } else {
319
+ UnsafePromotion (warm, eff.source, state.path, errs.toList).toErrors
320
+ }
321
+
288
322
private def checkPromote (eff : Promote )(using state : State ): Errors =
289
323
if (state.safePromoted.contains(eff.potential)) Errors .empty
290
324
else {
@@ -300,8 +334,7 @@ object Checking {
300
334
PromoteCold (eff.source, state.path).toErrors
301
335
302
336
case pot @ Warm (cls, outer) =>
303
- // TODO: Implement Rule 2
304
- PromoteWarm (pot, eff.source, state.path).toErrors
337
+ checkPromoteWarm(pot, eff)
305
338
306
339
case Fun (pots, effs) =>
307
340
val errs1 = state.test {
0 commit comments