@@ -1456,10 +1456,25 @@ DirectLookupRequest::evaluate(Evaluator &evaluator,
14561456 auto allFound = evaluateOrDefault (
14571457 ctx.evaluator , CXXNamespaceMemberLookup ({cast<EnumDecl>(decl), name}),
14581458 {});
1459- for (auto found : allFound)
1460- Table.addMember (found);
1461-
14621459 populateLookupTableEntryFromExtensions (ctx, Table, baseName, decl);
1460+
1461+ // Bypass the regular member lookup table if we find something in
1462+ // the original C++ namespace. We don't want to store the C++ decl in the
1463+ // lookup table as the decl can be referenced from multiple namespace
1464+ // declarations due to inline namespaces. We still merge in the other
1465+ // entries found in the lookup table, to support finding members in
1466+ // namespace extensions.
1467+ if (!allFound.empty ()) {
1468+ auto known = Table.find (name);
1469+ if (known != Table.end ()) {
1470+ auto swiftLookupResult = maybeFilterOutAttrImplements (
1471+ known->second , name, includeAttrImplements);
1472+ for (auto foundSwiftDecl : swiftLookupResult) {
1473+ allFound.push_back (foundSwiftDecl);
1474+ }
1475+ }
1476+ return allFound;
1477+ }
14631478 } else if (isa_and_nonnull<clang::RecordDecl>(decl->getClangDecl ())) {
14641479 auto allFound = evaluateOrDefault (
14651480 ctx.evaluator ,
0 commit comments