@@ -4492,11 +4492,6 @@ namespace {
44924492 const clang::ObjCProtocolList &clangProtocols,
44934493 SmallVectorImpl<TypeLoc> &inheritedTypes);
44944494
4495- // / Add conformances to the given Objective-C protocols to the
4496- // / given declaration.
4497- void addObjCProtocolConformances (Decl *decl,
4498- ArrayRef<ProtocolDecl*> protocols);
4499-
45004495 // Returns None on error. Returns nullptr if there is no type param list to
45014496 // import or we suppress its import, as in the case of NSArray, NSSet, and
45024497 // NSDictionary.
@@ -4517,7 +4512,6 @@ namespace {
45174512 // / methods become class methods on NSObject).
45184513 void importMirroredProtocolMembers (const clang::ObjCContainerDecl *decl,
45194514 DeclContext *dc,
4520- ArrayRef<ProtocolDecl *> protocols,
45214515 SmallVectorImpl<Decl *> &members);
45224516
45234517 void importNonOverriddenMirroredMethods (DeclContext *dc,
@@ -6860,22 +6854,7 @@ void SwiftDeclConverter::importObjCProtocols(
68606854 }
68616855 }
68626856
6863- addObjCProtocolConformances (decl, protocols);
6864- }
6865-
6866- void SwiftDeclConverter::addObjCProtocolConformances (
6867- Decl *decl, ArrayRef<ProtocolDecl *> protocols) {
6868- // Nothing to do for protocols.
6869- if (isa<ProtocolDecl>(decl)) return ;
6870-
68716857 Impl.recordImportedProtocols (decl, protocols);
6872-
6873- if (auto nominal = dyn_cast<NominalTypeDecl>(decl)) {
6874- nominal->setConformanceLoader (&Impl, 0 );
6875- } else {
6876- auto ext = cast<ExtensionDecl>(decl);
6877- ext->setConformanceLoader (&Impl, 0 );
6878- }
68796858}
68806859
68816860Optional<GenericParamList *> SwiftDeclConverter::importObjCGenericParams (
@@ -6940,22 +6919,18 @@ Optional<GenericParamList *> SwiftDeclConverter::importObjCGenericParams(
69406919
69416920void SwiftDeclConverter::importMirroredProtocolMembers (
69426921 const clang::ObjCContainerDecl *decl, DeclContext *dc,
6943- ArrayRef<ProtocolDecl *> protocols, SmallVectorImpl<Decl *> &members) {
6922+ SmallVectorImpl<Decl *> &members) {
69446923 assert (dc);
69456924 const clang::ObjCInterfaceDecl *interfaceDecl = nullptr ;
69466925 const ClangModuleUnit *declModule;
69476926 const ClangModuleUnit *interfaceModule;
69486927
6949- // 'protocols' is, for some reason, the full recursive expansion of
6950- // the protocol hierarchy, so there's no need to recursively descend
6951- // into inherited protocols.
6952-
69536928 // Try to import only the most specific methods with a particular name.
69546929 // We use a MapVector to get deterministic iteration order later.
69556930 llvm::MapVector<clang::Selector, std::vector<MirroredMethodEntry>>
69566931 methodsByName;
69576932
6958- for (auto proto : protocols ) {
6933+ for (auto proto : Impl. getImportedProtocols (dc-> getAsDecl ()) ) {
69596934 auto clangProto =
69606935 cast_or_null<clang::ObjCProtocolDecl>(proto->getClangDecl ());
69616936 if (!clangProto)
@@ -8600,20 +8575,6 @@ bool ClangImporter::Implementation::addMemberAndAlternatesToExtension(
86008575 return true ;
86018576}
86028577
8603- static ExtensionDecl *
8604- figureOutTheDeclarationContextToImportInto (Decl *D, DeclContext *&DC,
8605- IterableDeclContext *&IDC) {
8606- if (auto *nominal = dyn_cast<NominalTypeDecl>(D)) {
8607- DC = nominal;
8608- IDC = nominal;
8609- return nullptr ;
8610- }
8611- ExtensionDecl *ext = cast<ExtensionDecl>(D);
8612- DC = ext;
8613- IDC = ext;
8614- return ext;
8615- }
8616-
86178578static void loadMembersOfBaseImportedFromClang (ExtensionDecl *ext) {
86188579 const NominalTypeDecl *base = ext->getExtendedNominal ();
86198580 auto *clangBase = base->getClangDecl ();
@@ -8635,19 +8596,18 @@ void ClangImporter::Implementation::loadAllMembersOfObjcContainer(
86358596 Instance->getSourceManager (),
86368597 " loading members for" );
86378598
8638- DeclContext *DC;
8639- IterableDeclContext *IDC;
8640- if (ExtensionDecl *ext =
8641- figureOutTheDeclarationContextToImportInto (D, DC, IDC)) {
8642- // If the base is also imported from Clang, load its members first.
8599+ assert (isa<ExtensionDecl>(D) || isa<NominalTypeDecl>(D));
8600+ if (auto *ext = dyn_cast<ExtensionDecl>(D)) {
8601+ // If the extended type is also imported from Clang, load its members first.
86438602 loadMembersOfBaseImportedFromClang (ext);
86448603 }
86458604
86468605 startedImportingEntity ();
86478606
86488607 SmallVector<Decl *, 16 > members;
8649- collectMembersToAdd (objcContainer, D, DC , members);
8608+ collectMembersToAdd (objcContainer, D, cast<DeclContext>(D) , members);
86508609
8610+ auto *IDC = cast<IterableDeclContext>(D);
86518611 for (auto member : members) {
86528612 if (!isa<AccessorDecl>(member))
86538613 IDC->addMember (member);
@@ -8701,8 +8661,6 @@ void ClangImporter::Implementation::collectMembersToAdd(
87018661 }
87028662
87038663 SwiftDeclConverter converter (*this , CurrentVersion);
8704-
8705- auto protos = getImportedProtocols (D);
87068664 if (auto clangClass = dyn_cast<clang::ObjCInterfaceDecl>(objcContainer)) {
87078665 objcContainer = clangClass = clangClass->getDefinition ();
87088666 importInheritedConstructors (clangClass, cast<ClassDecl>(D), members);
@@ -8713,7 +8671,7 @@ void ClangImporter::Implementation::collectMembersToAdd(
87138671 // Import mirrored declarations for protocols to which this category
87148672 // or extension conforms.
87158673 // FIXME: This is supposed to be a short-term hack.
8716- converter.importMirroredProtocolMembers (objcContainer, DC, protos, members);
8674+ converter.importMirroredProtocolMembers (objcContainer, DC, members);
87178675}
87188676
87198677void ClangImporter::Implementation::loadAllConformances (
0 commit comments