Skip to content

Commit 36dd677

Browse files
committed
[Macros] Don't stop lookup early if we found a macro.
1 parent 806b5a8 commit 36dd677

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lib/AST/ModuleNameLookup.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,12 @@ void ModuleNameLookup<LookupStrategy>::lookupInModule(
176176
getDerived()->canReturnEarly());
177177
if (canReturnEarly &&
178178
resolutionKind == ResolutionKind::Overloadable) {
179-
// If we only found top-level functions, keep looking, since we may
180-
// find additional overloads.
179+
// If we only found top-level functions or macros, keep looking, since
180+
// we may find additional overloads.
181181
if (std::all_of(decls.begin() + initialCount, decls.end(),
182-
[](ValueDecl *VD) { return isa<FuncDecl>(VD); }))
182+
[](ValueDecl *VD) {
183+
return isa<FuncDecl>(VD) || isa<MacroDecl>(VD);
184+
}))
183185
canReturnEarly = false;
184186
}
185187

test/Macros/macro_expand_variadic.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
// FIXME: Swift parser is not enabled on Linux CI yet.
1010
// REQUIRES: OS=macosx
1111

12-
@expression macro varPrint<Value...>(_ value: Value...) = MacroDefinition.PrintMacro
12+
@expression macro print<Value...>(_ value: Value...) = MacroDefinition.PrintMacro
1313

1414
func testIt() {
1515
// CHECK: hello
1616
// CHECK: [1, 2, 3, 4, 5]
17-
#varPrint("hello", [1, 2, 3, 4, 5])
17+
#print("hello", [1, 2, 3, 4, 5])
1818

1919
// CHECK: world
20-
#varPrint("world")
20+
#print("world")
2121
}
2222

2323
testIt()

0 commit comments

Comments
 (0)