@@ -3041,37 +3041,30 @@ void ClangImporter::Implementation::lookupObjCMembers(
3041
3041
// If the entry is not visible, skip it.
3042
3042
if (!isVisibleClangEntry (clangCtx, clangDecl)) continue ;
3043
3043
3044
- // Import the declaration.
3045
- auto decl =
3046
- cast_or_null<ValueDecl>(importDeclReal (clangDecl, CurrentVersion));
3047
- if (!decl)
3048
- continue ;
3049
-
3050
- // If the name we found matches, report the declaration.
3051
- bool matchedAny = false ;
3052
- if (decl->getFullName ().matchesRef (name)) {
3053
- consumer.foundDecl (decl, DeclVisibilityKind::DynamicLookup);
3054
- matchedAny = true ;
3055
- }
3044
+ forEachDistinctName (clangDecl,
3045
+ [&](ImportedName importedName,
3046
+ ImportNameVersion nameVersion) {
3047
+ // Import the declaration.
3048
+ auto decl =
3049
+ cast_or_null<ValueDecl>(importDeclReal (clangDecl, nameVersion));
3050
+ if (!decl)
3051
+ return ;
3056
3052
3057
- // Check for an alternate declaration; if it's name matches,
3058
- // report it.
3059
- for (auto alternate : getAlternateDecls (decl)) {
3060
- if (alternate->getFullName ().matchesRef (name)) {
3061
- consumer.foundDecl (alternate, DeclVisibilityKind::DynamicLookup);
3062
- matchedAny = true ;
3053
+ // If the name we found matches, report the declaration.
3054
+ // FIXME: If we didn't need to check alternate decls here, we could avoid
3055
+ // importing the member at all by checking importedName ahead of time.
3056
+ if (decl->getFullName ().matchesRef (name)) {
3057
+ consumer.foundDecl (decl, DeclVisibilityKind::DynamicLookup);
3063
3058
}
3064
- }
3065
3059
3066
- // If we didn't find anything, try under the Swift 2 name.
3067
- if (!matchedAny) {
3068
- if (auto swift2Decl = cast_or_null<ValueDecl>(
3069
- importDeclReal (clangDecl, Version::Swift2))) {
3070
- if (swift2Decl->getFullName ().matchesRef (name)) {
3071
- consumer.foundDecl (swift2Decl, DeclVisibilityKind::DynamicLookup);
3060
+ // Check for an alternate declaration; if its name matches,
3061
+ // report it.
3062
+ for (auto alternate : getAlternateDecls (decl)) {
3063
+ if (alternate->getFullName ().matchesRef (name)) {
3064
+ consumer.foundDecl (alternate, DeclVisibilityKind::DynamicLookup);
3072
3065
}
3073
3066
}
3074
- }
3067
+ });
3075
3068
}
3076
3069
}
3077
3070
0 commit comments