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