@@ -813,26 +813,31 @@ SILIsolationInfo SILIsolationInfo::get(SILArgument *arg) {
813813 }
814814 }
815815
816- // Otherwise, see if we have an allocator decl ref. If we do and we have an
817- // actor instance isolation, then we know that we are actively just calling
818- // the initializer. To just make region isolation work, treat this as
819- // disconnected so we can construct the actor value. Users cannot write
820- // allocator functions so we just need to worry about compiler generated
821- // code. In the case of a non-actor, we can only have an allocator that is
822- // global actor isolated, so we will never hit this code path.
816+ // Otherwise, see if we need to handle this isolation computation specially
817+ // due to information from the decl ref if we have one.
823818 if (auto declRef = fArg ->getFunction ()->getDeclRef ()) {
819+ // First check if we have an allocator decl ref. If we do and we have an
820+ // actor instance isolation, then we know that we are actively just calling
821+ // the initializer. To just make region isolation work, treat this as
822+ // disconnected so we can construct the actor value. Users cannot write
823+ // allocator functions so we just need to worry about compiler generated
824+ // code. In the case of a non-actor, we can only have an allocator that is
825+ // global actor isolated, so we will never hit this code path.
824826 if (declRef.kind == SILDeclRef::Kind::Allocator) {
825827 if (fArg ->getFunction ()->getActorIsolation ().isActorInstanceIsolated ()) {
826828 return SILIsolationInfo::getDisconnected (false /* nonisolated(unsafe)*/ );
827829 }
828830 }
829831
832+ // Then see if we have an init accessor that is isolated to an actor
833+ // instance, but for which we have not actually passed self. In such a case,
834+ // we need to pass in a "fake" ActorInstance that users know is a sentinel
835+ // for the self value.
830836 if (auto functionIsolation = fArg ->getFunction ()->getActorIsolation ()) {
831- if (declRef.getDecl ()) {
837+ if (functionIsolation. isActorInstanceIsolated () && declRef.getDecl ()) {
832838 if (auto *accessor =
833839 dyn_cast_or_null<AccessorDecl>(declRef.getFuncDecl ())) {
834840 if (accessor->isInitAccessor ()) {
835- assert (functionIsolation.isActorInstanceIsolated ());
836841 return SILIsolationInfo::getActorInstanceIsolated (
837842 fArg , ActorInstance::getForActorAccessorInit (),
838843 functionIsolation.getActor ());
0 commit comments