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