@@ -1255,6 +1255,7 @@ class swift::MemberLookupTable : public ASTAllocated<swift::MemberLookupTable> {
12551255 }
12561256
12571257 bool isLazilyCompleteForMacroExpansion (DeclName name) const {
1258+ assert (!MacroDecl::isUniqueMacroName (name.getBaseName ()));
12581259 // If we've already expanded macros for a simple name, we must have expanded
12591260 // all macros that produce names with the same base identifier.
12601261 bool isBaseNameComplete = name.isCompoundName () &&
@@ -1264,6 +1265,7 @@ class swift::MemberLookupTable : public ASTAllocated<swift::MemberLookupTable> {
12641265 }
12651266
12661267 void markLazilyCompleteForMacroExpansion (DeclName name) {
1268+ assert (!MacroDecl::isUniqueMacroName (name.getBaseName ()));
12671269 LazilyCompleteNamesForMacroExpansion.insert (name);
12681270 }
12691271
@@ -1521,6 +1523,17 @@ populateLookupTableEntryFromExtensions(ASTContext &ctx,
15211523 }
15221524}
15231525
1526+ // / Adjust the given name to make it a proper key for the lazy macro expansion
1527+ // / cache, which maps all uniquely-generated names down to a single placeholder
1528+ // / key.
1529+ static DeclName adjustLazyMacroExpansionNameKey (
1530+ ASTContext &ctx, DeclName name) {
1531+ if (MacroDecl::isUniqueMacroName (name.getBaseName ()))
1532+ return MacroDecl::getUniqueNamePlaceholder (ctx);
1533+
1534+ return name;
1535+ }
1536+
15241537static void
15251538populateLookupTableEntryFromMacroExpansions (ASTContext &ctx,
15261539 MemberLookupTable &table,
@@ -1756,9 +1769,11 @@ DirectLookupRequest::evaluate(Evaluator &evaluator,
17561769 Table.markLazilyComplete (baseName);
17571770 }
17581771
1759- if (!Table.isLazilyCompleteForMacroExpansion (name)) {
1760- populateLookupTableEntryFromMacroExpansions (ctx, Table, name, decl);
1761- Table.markLazilyCompleteForMacroExpansion (name);
1772+ DeclName macroExpansionKey = adjustLazyMacroExpansionNameKey (ctx, name);
1773+ if (!Table.isLazilyCompleteForMacroExpansion (macroExpansionKey)) {
1774+ populateLookupTableEntryFromMacroExpansions (
1775+ ctx, Table, macroExpansionKey, decl);
1776+ Table.markLazilyCompleteForMacroExpansion (macroExpansionKey);
17621777 }
17631778
17641779 // Look for a declaration with this name.
0 commit comments