@@ -4492,11 +4492,6 @@ namespace {
4492
4492
const clang::ObjCProtocolList &clangProtocols,
4493
4493
SmallVectorImpl<TypeLoc> &inheritedTypes);
4494
4494
4495
- // / Add conformances to the given Objective-C protocols to the
4496
- // / given declaration.
4497
- void addObjCProtocolConformances (Decl *decl,
4498
- ArrayRef<ProtocolDecl*> protocols);
4499
-
4500
4495
// Returns None on error. Returns nullptr if there is no type param list to
4501
4496
// import or we suppress its import, as in the case of NSArray, NSSet, and
4502
4497
// NSDictionary.
@@ -4517,7 +4512,6 @@ namespace {
4517
4512
// / methods become class methods on NSObject).
4518
4513
void importMirroredProtocolMembers (const clang::ObjCContainerDecl *decl,
4519
4514
DeclContext *dc,
4520
- ArrayRef<ProtocolDecl *> protocols,
4521
4515
SmallVectorImpl<Decl *> &members);
4522
4516
4523
4517
void importNonOverriddenMirroredMethods (DeclContext *dc,
@@ -6860,22 +6854,7 @@ void SwiftDeclConverter::importObjCProtocols(
6860
6854
}
6861
6855
}
6862
6856
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
-
6871
6857
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
- }
6879
6858
}
6880
6859
6881
6860
Optional<GenericParamList *> SwiftDeclConverter::importObjCGenericParams (
@@ -6940,22 +6919,18 @@ Optional<GenericParamList *> SwiftDeclConverter::importObjCGenericParams(
6940
6919
6941
6920
void SwiftDeclConverter::importMirroredProtocolMembers (
6942
6921
const clang::ObjCContainerDecl *decl, DeclContext *dc,
6943
- ArrayRef<ProtocolDecl *> protocols, SmallVectorImpl<Decl *> &members) {
6922
+ SmallVectorImpl<Decl *> &members) {
6944
6923
assert (dc);
6945
6924
const clang::ObjCInterfaceDecl *interfaceDecl = nullptr ;
6946
6925
const ClangModuleUnit *declModule;
6947
6926
const ClangModuleUnit *interfaceModule;
6948
6927
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
-
6953
6928
// Try to import only the most specific methods with a particular name.
6954
6929
// We use a MapVector to get deterministic iteration order later.
6955
6930
llvm::MapVector<clang::Selector, std::vector<MirroredMethodEntry>>
6956
6931
methodsByName;
6957
6932
6958
- for (auto proto : protocols ) {
6933
+ for (auto proto : Impl. getImportedProtocols (dc-> getAsDecl ()) ) {
6959
6934
auto clangProto =
6960
6935
cast_or_null<clang::ObjCProtocolDecl>(proto->getClangDecl ());
6961
6936
if (!clangProto)
@@ -8600,20 +8575,6 @@ bool ClangImporter::Implementation::addMemberAndAlternatesToExtension(
8600
8575
return true ;
8601
8576
}
8602
8577
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
-
8617
8578
static void loadMembersOfBaseImportedFromClang (ExtensionDecl *ext) {
8618
8579
const NominalTypeDecl *base = ext->getExtendedNominal ();
8619
8580
auto *clangBase = base->getClangDecl ();
@@ -8635,19 +8596,18 @@ void ClangImporter::Implementation::loadAllMembersOfObjcContainer(
8635
8596
Instance->getSourceManager (),
8636
8597
" loading members for" );
8637
8598
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.
8643
8602
loadMembersOfBaseImportedFromClang (ext);
8644
8603
}
8645
8604
8646
8605
startedImportingEntity ();
8647
8606
8648
8607
SmallVector<Decl *, 16 > members;
8649
- collectMembersToAdd (objcContainer, D, DC , members);
8608
+ collectMembersToAdd (objcContainer, D, cast<DeclContext>(D) , members);
8650
8609
8610
+ auto *IDC = cast<IterableDeclContext>(D);
8651
8611
for (auto member : members) {
8652
8612
if (!isa<AccessorDecl>(member))
8653
8613
IDC->addMember (member);
@@ -8701,8 +8661,6 @@ void ClangImporter::Implementation::collectMembersToAdd(
8701
8661
}
8702
8662
8703
8663
SwiftDeclConverter converter (*this , CurrentVersion);
8704
-
8705
- auto protos = getImportedProtocols (D);
8706
8664
if (auto clangClass = dyn_cast<clang::ObjCInterfaceDecl>(objcContainer)) {
8707
8665
objcContainer = clangClass = clangClass->getDefinition ();
8708
8666
importInheritedConstructors (clangClass, cast<ClassDecl>(D), members);
@@ -8713,7 +8671,7 @@ void ClangImporter::Implementation::collectMembersToAdd(
8713
8671
// Import mirrored declarations for protocols to which this category
8714
8672
// or extension conforms.
8715
8673
// FIXME: This is supposed to be a short-term hack.
8716
- converter.importMirroredProtocolMembers (objcContainer, DC, protos, members);
8674
+ converter.importMirroredProtocolMembers (objcContainer, DC, members);
8717
8675
}
8718
8676
8719
8677
void ClangImporter::Implementation::loadAllConformances (
0 commit comments