@@ -1228,7 +1228,7 @@ namespace {
12281228 const ClassLayout &fieldLayout)
12291229 : IGM(IGM), TheEntity(theUnion), TheExtension(nullptr ),
12301230 FieldLayout (&fieldLayout) {
1231- visitConformances (getClass ()-> getImplementationContext () );
1231+ visitConformances (getClass ());
12321232
12331233 if (getClass ()->isRootDefaultActor ()) {
12341234 Ivars.push_back (Field::DefaultActorStorage);
@@ -1249,7 +1249,7 @@ namespace {
12491249 FieldLayout(nullptr ) {
12501250 buildCategoryName (CategoryName);
12511251
1252- visitConformances (theExtension-> getImplementationContext () );
1252+ visitConformances (theExtension);
12531253
12541254 for (Decl *member : TheExtension->getImplementationContext ()->getMembers ())
12551255 visit (member);
@@ -1295,6 +1295,15 @@ namespace {
12951295 // / Gather protocol records for all of the explicitly-specified Objective-C
12961296 // / protocol conformances.
12971297 void visitConformances (const IterableDeclContext *idc) {
1298+ auto dc = idc->getAsGenericContext ();
1299+ if (dc->getImplementedObjCContext () != dc) {
1300+ // We want to use the conformance list imported from the ObjC header.
1301+ auto importedIDC = cast<IterableDeclContext>(
1302+ dc->getImplementedObjCContext ()->getAsDecl ());
1303+ visitConformances (importedIDC);
1304+ return ;
1305+ }
1306+
12981307 llvm::SmallSetVector<ProtocolDecl *, 2 > protocols;
12991308 for (auto conformance : idc->getLocalConformances (
13001309 ConformanceLookupKind::OnlyExplicit)) {
0 commit comments