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