File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
compiler/src/dotty/tools/dotc/transform/init Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -270,7 +270,7 @@ object Checking {
270
270
// / A potential can be (currently) directly promoted if and only if:
271
271
// / - `pot == this` and all fields of this are initialized, or
272
272
// / - `pot == Warm(C, outer)` where `outer` can be directly promoted.
273
- private def canDirectlyPromote (pot : Potential )(using state : State ): Boolean =
273
+ private def canDirectlyPromote (pot : Potential )(using state : State ): Boolean = trace( " checking direct promotion of " + pot.show, init) {
274
274
if (state.safePromoted.contains(pot)) true
275
275
else pot match {
276
276
case pot : ThisRef =>
@@ -282,8 +282,13 @@ object Checking {
282
282
}
283
283
case Warm (cls, outer) =>
284
284
canDirectlyPromote(outer)
285
- case _ => false
285
+ case _ =>
286
+ val summary = expand(pot)
287
+ if (! summary.effs.isEmpty)
288
+ false // max depth of expansion reached
289
+ else summary.pots.forall(canDirectlyPromote)
286
290
}
291
+ }
287
292
288
293
// / Check the Promotion of a Warm object, according to "Rule 2":
289
294
//
You can’t perform that action at this time.
0 commit comments