@@ -813,26 +813,31 @@ SILIsolationInfo SILIsolationInfo::get(SILArgument *arg) {
813
813
}
814
814
}
815
815
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.
823
818
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.
824
826
if (declRef.kind == SILDeclRef::Kind::Allocator) {
825
827
if (fArg ->getFunction ()->getActorIsolation ().isActorInstanceIsolated ()) {
826
828
return SILIsolationInfo::getDisconnected (false /* nonisolated(unsafe)*/ );
827
829
}
828
830
}
829
831
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.
830
836
if (auto functionIsolation = fArg ->getFunction ()->getActorIsolation ()) {
831
- if (declRef.getDecl ()) {
837
+ if (functionIsolation. isActorInstanceIsolated () && declRef.getDecl ()) {
832
838
if (auto *accessor =
833
839
dyn_cast_or_null<AccessorDecl>(declRef.getFuncDecl ())) {
834
840
if (accessor->isInitAccessor ()) {
835
- assert (functionIsolation.isActorInstanceIsolated ());
836
841
return SILIsolationInfo::getActorInstanceIsolated (
837
842
fArg , ActorInstance::getForActorAccessorInit (),
838
843
functionIsolation.getActor ());
0 commit comments