@@ -602,40 +602,55 @@ SILIsolationInfo SILIsolationInfo::get(SILInstruction *inst) {
602602 bool isNonIsolatedUnsafe = exprAnalysis.hasNonisolatedUnsafe ();
603603 {
604604 auto isolation = swift::getActorIsolation (dre->getDecl ());
605- if (isolation.isActorIsolated () &&
606- (isolation.getKind () != ActorIsolation::ActorInstance ||
607- isolation.getActorInstanceParameter () == 0 )) {
608- if (cmi->getOperand ()->getType ().isAnyActor ()) {
605+
606+ if (isolation.isActorIsolated ()) {
607+ // Check if we have a global actor and handle it appropriately.
608+ if (isolation.getKind () == ActorIsolation::GlobalActor) {
609+ bool localNonIsolatedUnsafe =
610+ isNonIsolatedUnsafe | isolation.isNonisolatedUnsafe ();
611+ return SILIsolationInfo::getGlobalActorIsolated (
612+ cmi, isolation.getGlobalActor ())
613+ .withUnsafeNonIsolated (localNonIsolatedUnsafe);
614+ }
615+
616+ // In this case, we have an actor instance that is self.
617+ if (isolation.getKind () != ActorIsolation::ActorInstance &&
618+ isolation.isActorInstanceForSelfParameter ()) {
619+ bool localNonIsolatedUnsafe =
620+ isNonIsolatedUnsafe | isolation.isNonisolatedUnsafe ();
609621 return SILIsolationInfo::getActorInstanceIsolated (
610- cmi, cmi->getOperand (),
611- cmi->getOperand ()
612- ->getType ()
613- .getNominalOrBoundGenericNominal ());
622+ cmi, cmi->getOperand (),
623+ cmi->getOperand ()
624+ ->getType ()
625+ .getNominalOrBoundGenericNominal ())
626+ .withUnsafeNonIsolated (localNonIsolatedUnsafe);
614627 }
615- return SILIsolationInfo::getGlobalActorIsolated (
616- cmi, isolation.getGlobalActor ());
617628 }
618-
619- isNonIsolatedUnsafe |= isolation.isNonisolatedUnsafe ();
620629 }
621630
622631 if (auto type = dre->getType ()->getNominalOrBoundGenericNominal ()) {
623632 if (auto isolation = swift::getActorIsolation (type)) {
624- if (isolation.isActorIsolated () &&
625- (isolation.getKind () != ActorIsolation::ActorInstance ||
626- isolation.getActorInstanceParameter () == 0 )) {
627- if (cmi->getOperand ()->getType ().isAnyActor ()) {
633+ if (isolation.isActorIsolated ()) {
634+ // Check if we have a global actor and handle it appropriately.
635+ if (isolation.getKind () == ActorIsolation::GlobalActor) {
636+ bool localNonIsolatedUnsafe =
637+ isNonIsolatedUnsafe | isolation.isNonisolatedUnsafe ();
638+ return SILIsolationInfo::getGlobalActorIsolated (
639+ cmi, isolation.getGlobalActor ())
640+ .withUnsafeNonIsolated (localNonIsolatedUnsafe);
641+ }
642+
643+ // In this case, we have an actor instance that is self.
644+ if (isolation.getKind () != ActorIsolation::ActorInstance &&
645+ isolation.isActorInstanceForSelfParameter ()) {
646+ bool localNonIsolatedUnsafe =
647+ isNonIsolatedUnsafe | isolation.isNonisolatedUnsafe ();
628648 return SILIsolationInfo::getActorInstanceIsolated (
629649 cmi, cmi->getOperand (),
630650 cmi->getOperand ()
631651 ->getType ()
632652 .getNominalOrBoundGenericNominal ())
633- .withUnsafeNonIsolated (isNonIsolatedUnsafe);
634- }
635-
636- if (auto globalIso = SILIsolationInfo::getGlobalActorIsolated (
637- cmi, isolation.getGlobalActor ())) {
638- return globalIso.withUnsafeNonIsolated (isNonIsolatedUnsafe);
653+ .withUnsafeNonIsolated (localNonIsolatedUnsafe);
639654 }
640655 }
641656 }
0 commit comments