Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Serialization] Force destructor creation for imported class for SIB deserialization #33255

Merged
merged 1 commit into from Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/Serialization/Deserialization.cpp
Expand Up @@ -1611,6 +1611,14 @@ ModuleFile::resolveCrossReference(ModuleID MID, uint32_t pathLen) {
getXRefDeclNameForError());
}

if (memberName.getKind() == DeclBaseName::Kind::Destructor) {
assert(isa<ClassDecl>(nominal));
// Force creation of an implicit destructor
auto CD = dyn_cast<ClassDecl>(nominal);
values.push_back(CD->getDestructor());
break;
}

if (!privateDiscriminator.empty()) {
ModuleDecl *searchModule = M;
if (!searchModule)
Expand Down
4 changes: 4 additions & 0 deletions test/Serialization/Inputs/objc-xref/module.modulemap
@@ -0,0 +1,4 @@
module ObjCXRef {
header "objc_xref.h"
export *
}
2 changes: 2 additions & 0 deletions test/Serialization/Inputs/objc-xref/objc_xref.h
@@ -0,0 +1,2 @@
@interface MyObject
@end
9 changes: 9 additions & 0 deletions test/Serialization/xref-deinit.swift
@@ -0,0 +1,9 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-sib %s -o %t/xref-deinit.sib -I%t -I %S/Inputs/objc-xref
// RUN: %target-swift-frontend -emit-sil %t/xref-deinit.sib -I%t -I %S/Inputs/objc-xref

// REQUIRES: objc_interop

import ObjCXRef

public class Object: MyObject {}