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