@@ -3010,7 +3010,7 @@ void ClangImporter::loadExtensions(NominalTypeDecl *nominal,
3010
3010
// FIXME: If we already looked at this for this generation,
3011
3011
// skip.
3012
3012
3013
- for (auto entry : table.lookupGlobalsAsMembers (effectiveClangContext)) {
3013
+ for (auto entry : table.allGlobalsAsMembersInContext (effectiveClangContext)) {
3014
3014
// If the entry is not visible, skip it.
3015
3015
if (!isVisibleClangEntry (clangCtx, entry)) continue ;
3016
3016
@@ -3786,17 +3786,6 @@ ClangImporter::Implementation::loadNamedMembers(
3786
3786
return None;
3787
3787
}
3788
3788
3789
- // Also bail out if there are any global-as-member mappings for this context;
3790
- // we can support some of them lazily but the full set of idioms seems
3791
- // prohibitively complex (also they're not stored in by-name lookup, for
3792
- // reasons unclear).
3793
- if (isa<ExtensionDecl>(D) && !checkedGlobalsAsMembers.insert (IDC).second ) {
3794
- if (forEachLookupTable ([&](SwiftLookupTable &table) -> bool {
3795
- return (!table.lookupGlobalsAsMembers (effectiveClangContext).empty ());
3796
- }))
3797
- return None;
3798
- }
3799
-
3800
3789
// There are 3 cases:
3801
3790
//
3802
3791
// - The decl is from a bridging header, CMO is Some(nullptr)
@@ -3846,6 +3835,27 @@ ClangImporter::Implementation::loadNamedMembers(
3846
3835
}
3847
3836
}
3848
3837
3838
+ for (auto entry : table->lookupGlobalsAsMembers (SerializedSwiftName (N),
3839
+ effectiveClangContext)) {
3840
+ if (!entry.is <clang::NamedDecl *>()) continue ;
3841
+ auto member = entry.get <clang::NamedDecl *>();
3842
+ if (!isVisibleClangEntry (clangCtx, member)) continue ;
3843
+
3844
+ // Skip Decls from different clang::DeclContexts
3845
+ if (member->getDeclContext () != CDC) continue ;
3846
+
3847
+ SmallVector<Decl*, 4 > tmp;
3848
+ insertMembersAndAlternates (member, tmp);
3849
+ for (auto *TD : tmp) {
3850
+ if (auto *V = dyn_cast<ValueDecl>(TD)) {
3851
+ // Skip ValueDecls if they import under different names.
3852
+ if (V->getBaseName () == N) {
3853
+ Members.push_back (V);
3854
+ }
3855
+ }
3856
+ }
3857
+ }
3858
+
3849
3859
if (N == DeclBaseName::createConstructor ()) {
3850
3860
if (auto *classDecl = dyn_cast<ClassDecl>(D)) {
3851
3861
SmallVector<Decl *, 4 > ctors;
0 commit comments