Skip to content

Commit a52b095

Browse files
committed
ClangImporter: Targeted fix for <rdar://problem/29081276>
1 parent f220ad2 commit a52b095

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3892,6 +3892,27 @@ namespace {
38923892
}
38933893
result->setSuperclass(superclassType);
38943894

3895+
// Mark the class as runtime-only if it is named 'OS_object', even
3896+
// if it doesn't have the runtime-only Clang attribute. This is a
3897+
// targeted fix allowing IRGen to emit convenience initializers
3898+
// correctly.
3899+
//
3900+
// FIXME: Remove this once SILGen gets proper support for factory
3901+
// initializers.
3902+
if (result->getName() ==
3903+
result->getASTContext().getIdentifier("OS_object")) {
3904+
result->setForeignClassKind(ClassDecl::ForeignKind::RuntimeOnly);
3905+
}
3906+
3907+
// If the superclass is runtime-only, our class is also. This only
3908+
// matters in the case above.
3909+
if (superclassType) {
3910+
auto superclassDecl = cast<ClassDecl>(superclassType->getAnyNominal());
3911+
auto kind = superclassDecl->getForeignClassKind();
3912+
if (kind != ClassDecl::ForeignKind::Normal)
3913+
result->setForeignClassKind(kind);
3914+
}
3915+
38953916
// Import protocols this class conforms to.
38963917
importObjCProtocols(result, decl->getReferencedProtocols(),
38973918
inheritedTypes);

0 commit comments

Comments
 (0)