@@ -7299,6 +7299,18 @@ RValue RValueEmitter::visitCurrentContextIsolationExpr(
72997299 dyn_cast_or_null<AbstractFunctionDecl>(SGF.F .getDeclRef ().getDecl ());
73007300 if (afd) {
73017301 auto isolation = getActorIsolation (afd);
7302+ auto ctor = dyn_cast_or_null<ConstructorDecl>(afd);
7303+ if (ctor && ctor->isDesignatedInit () &&
7304+ isolation == ActorIsolation::ActorInstance &&
7305+ isolation.getActorInstance () == ctor->getImplicitSelfDecl ()) {
7306+ // If we are in an actor initializer that is isolated to self, the
7307+ // current isolation is flow-sensitive; use that instead of the
7308+ // synthesized expression.
7309+ auto isolationValue =
7310+ SGF.emitFlowSensitiveSelfIsolation (E, isolation);
7311+ return RValue (SGF, E, isolationValue);
7312+ }
7313+
73027314 if (isolation == ActorIsolation::CallerIsolationInheriting) {
73037315 auto *isolatedArg = SGF.F .maybeGetIsolatedArgument ();
73047316 assert (isolatedArg &&
@@ -7311,18 +7323,6 @@ RValue RValueEmitter::visitCurrentContextIsolationExpr(
73117323 }
73127324 return RValue (SGF, E, isolatedMV);
73137325 }
7314-
7315- auto ctor = dyn_cast_or_null<ConstructorDecl>(afd);
7316- if (ctor && ctor->isDesignatedInit () &&
7317- isolation == ActorIsolation::ActorInstance &&
7318- isolation.getActorInstance () == ctor->getImplicitSelfDecl ()) {
7319- // If we are in an actor initializer that is isolated to self, the
7320- // current isolation is flow-sensitive; use that instead of the
7321- // synthesized expression.
7322- auto isolationValue =
7323- SGF.emitFlowSensitiveSelfIsolation (E, isolation);
7324- return RValue (SGF, E, isolationValue);
7325- }
73267326 }
73277327
73287328 return visit (E->getActor (), C);
0 commit comments