Skip to content

Commit 6b0ce0b

Browse files
Added emitting precondition check in the isolated deinit
1 parent 8dbddec commit 6b0ce0b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/SILGen/SILGenDestructor.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,26 @@ void SILGenFunction::emitDestroyingDestructor(DestructorDecl *dd) {
114114

115115
auto cd = cast<ClassDecl>(dd->getDeclContext());
116116
SILValue selfValue = emitSelfDeclForDestructor(dd->getImplicitSelfDecl());
117+
ManagedValue managedSelf;
118+
if (selfValue->getOwnershipKind() == OwnershipKind::Unowned) {
119+
managedSelf = ManagedValue::forUnownedObjectValue(selfValue);
120+
} else {
121+
managedSelf = ManagedValue::forBorrowedRValue(selfValue);
122+
}
123+
124+
auto ai = swift::getActorIsolation(dd);
125+
auto actor = emitExecutor(Loc, ai, managedSelf);
126+
if (actor) {
127+
ExpectedExecutor = *actor;
128+
}
129+
130+
// Jump to the expected executor.
131+
if (ExpectedExecutor) {
132+
// For a synchronous function, check that we're on the same executor.
133+
// Note: if we "know" that the code is completely Sendable-safe, this
134+
// is unnecessary. The type checker will need to make this determination.
135+
emitPreconditionCheckExpectedExecutor(Loc, ExpectedExecutor);
136+
}
117137

118138
// Create a basic block to jump to for the implicit destruction behavior
119139
// of releasing the elements and calling the superclass destructor.

0 commit comments

Comments
 (0)