@@ -1573,6 +1573,17 @@ bool SILGenModule::requiresIVarDestroyer(ClassDecl *cd) {
1573
1573
// / TODO: This needs a better name.
1574
1574
void SILGenModule::emitObjCAllocatorDestructor (ClassDecl *cd,
1575
1575
DestructorDecl *dd) {
1576
+
1577
+ const bool isActorIsolated = getActorIsolation (dd).isActorIsolated ();
1578
+
1579
+ // Emit the isolated deallocating destructor.
1580
+ // If emitted, it implements actual deallocating and deallocating destructor
1581
+ // only switches executor
1582
+ if (dd->hasBody () && isActorIsolated) {
1583
+ SILDeclRef dealloc (dd, SILDeclRef::Kind::IsolatedDeallocator);
1584
+ emitFunctionDefinition (dealloc, getFunction (dealloc, ForDefinition));
1585
+ }
1586
+
1576
1587
// Emit the native deallocating destructor for -dealloc.
1577
1588
// Destructors are a necessary part of class metadata, so can't be delayed.
1578
1589
if (shouldEmitFunctionBody (dd)) {
@@ -1581,7 +1592,7 @@ void SILGenModule::emitObjCAllocatorDestructor(ClassDecl *cd,
1581
1592
1582
1593
// Emit the Objective-C -dealloc entry point if it has
1583
1594
// something to do beyond messaging the superclass's -dealloc.
1584
- if (!dd->getBody ()->empty ())
1595
+ if (!dd->getBody ()->empty () || isActorIsolated )
1585
1596
emitObjCDestructorThunk (dd);
1586
1597
}
1587
1598
@@ -1649,7 +1660,7 @@ void SILGenModule::emitDestructor(ClassDecl *cd, DestructorDecl *dd) {
1649
1660
emitFunctionDefinition (destroyer, getFunction (destroyer, ForDefinition));
1650
1661
}
1651
1662
1652
- // Emit the deallocating destructor.
1663
+ // Emit the isolated deallocating destructor.
1653
1664
// If emitted, it implements actual deallocating and deallocating destructor
1654
1665
// only switches executor
1655
1666
if (getActorIsolation (dd).isActorIsolated ()) {
0 commit comments