Skip to content

Commit 4f8808d

Browse files
authored
Merge pull request #64967 from DougGregor/name-lookup-filtering-expanded-top-level
2 parents 05bcc88 + d790477 commit 4f8808d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/AST/Module.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,12 @@ void SourceLookupCache::lookupValue(DeclName Name, NLKind LookupKind,
444444
return;
445445

446446
for (auto *unexpandedDecl : auxDecls->second) {
447-
// Add expanded peers to the result.
447+
// Add expanded peers and freestanding declarations to the result.
448448
unexpandedDecl->forEachMacroExpandedDecl(
449449
[&](ValueDecl *decl) {
450-
Result.push_back(decl);
450+
if (decl->getName().matchesRef(Name)) {
451+
Result.push_back(decl);
452+
}
451453
});
452454
}
453455
}

test/Macros/macro_expand_peers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// RUN: %target-swift-frontend -swift-version 5 -typecheck -load-plugin-library %t/%target-library-name(MacroDefinition) -parse-as-library %s -disable-availability-checking -dump-macro-expansions > %t/expansions-dump.txt 2>&1
1818
// RUN: %FileCheck -check-prefix=CHECK-DUMP %s < %t/expansions-dump.txt
1919

20-
// RUN: %target-build-swift -swift-version 5 -Xfrontend -disable-availability-checking -load-plugin-library %t/%target-library-name(MacroDefinition) -parse-as-library %s -o %t/main -module-name MacroUser
20+
// RUN: %target-build-swift -swift-version 5 -Xfrontend -disable-availability-checking -load-plugin-library %t/%target-library-name(MacroDefinition) -parse-as-library %s -o %t/main -module-name MacroUser -g
2121
// RUN: %target-codesign %t/main
2222
// RUN: %target-run %t/main | %FileCheck %s -check-prefix=CHECK-EXEC
2323

0 commit comments

Comments
 (0)