Skip to content

Commit e387b36

Browse files
authored
Merge pull request #33255 from kateinoigakukun/katei/fix-sib-xref-deinit
[Serialization] Force destructor creation for imported class for SIB deserialization
2 parents 148ba9d + 878efac commit e387b36

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,14 @@ ModuleFile::resolveCrossReference(ModuleID MID, uint32_t pathLen) {
16111611
getXRefDeclNameForError());
16121612
}
16131613

1614+
if (memberName.getKind() == DeclBaseName::Kind::Destructor) {
1615+
assert(isa<ClassDecl>(nominal));
1616+
// Force creation of an implicit destructor
1617+
auto CD = dyn_cast<ClassDecl>(nominal);
1618+
values.push_back(CD->getDestructor());
1619+
break;
1620+
}
1621+
16141622
if (!privateDiscriminator.empty()) {
16151623
ModuleDecl *searchModule = M;
16161624
if (!searchModule)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ObjCXRef {
2+
header "objc_xref.h"
3+
export *
4+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@interface MyObject
2+
@end

test/Serialization/xref-deinit.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-sib %s -o %t/xref-deinit.sib -I%t -I %S/Inputs/objc-xref
3+
// RUN: %target-swift-frontend -emit-sil %t/xref-deinit.sib -I%t -I %S/Inputs/objc-xref
4+
5+
// REQUIRES: objc_interop
6+
7+
import ObjCXRef
8+
9+
public class Object: MyObject {}

0 commit comments

Comments
 (0)