@@ -601,40 +601,55 @@ SILIsolationInfo SILIsolationInfo::get(SILInstruction *inst) {
601
601
bool isNonIsolatedUnsafe = exprAnalysis.hasNonisolatedUnsafe ();
602
602
{
603
603
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 ();
608
620
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);
613
626
}
614
- return SILIsolationInfo::getGlobalActorIsolated (
615
- cmi, isolation.getGlobalActor ());
616
627
}
617
-
618
- isNonIsolatedUnsafe |= isolation.isNonisolatedUnsafe ();
619
628
}
620
629
621
630
if (auto type = dre->getType ()->getNominalOrBoundGenericNominal ()) {
622
631
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 ();
627
647
return SILIsolationInfo::getActorInstanceIsolated (
628
648
cmi, cmi->getOperand (),
629
649
cmi->getOperand ()
630
650
->getType ()
631
651
.getNominalOrBoundGenericNominal ())
632
- .withUnsafeNonIsolated (isNonIsolatedUnsafe);
633
- }
634
-
635
- if (auto globalIso = SILIsolationInfo::getGlobalActorIsolated (
636
- cmi, isolation.getGlobalActor ())) {
637
- return globalIso.withUnsafeNonIsolated (isNonIsolatedUnsafe);
652
+ .withUnsafeNonIsolated (localNonIsolatedUnsafe);
638
653
}
639
654
}
640
655
}
0 commit comments