swift
[Macros] Resolve macro names using unqualified lookup that ignores expansions
#64854
Merged

[Macros] Resolve macro names using unqualified lookup that ignores expansions #64854

DougGregor
DougGregor2 years ago🎉 1

The macro name resolution in the source lookup cache was only looking at macros in the current module, meaning that any names introduced by peer or declaration macros declared in one module but used in another would not be found by name lookup.

Switch the source lookup cache over to using the same forEachPotentialResolvedMacro API that is used by lookup within types, so we have consistent name-lookup-level macro resolution in both places.

... except that would be horribly cyclic, of course, so introduce name lookup flags to ignore top-level declarations introduced by macro expansions. This is semantically correct because macro expansions are not allowed to introduce new macros anyway, because that would have been a terrible idea.

Fixes rdar://107321469. Peer and declaration macros at module scope should work a whole lot better now.

DougGregor [Macros] Resolve macro names using unqualified lookup that ignores ex…
828de17b
DougGregor DougGregor requested a review from artemcm artemcm 2 years ago
DougGregor DougGregor requested a review from zoecarver zoecarver 2 years ago
DougGregor DougGregor requested a review from hyp hyp 2 years ago
DougGregor DougGregor requested a review from egorzhdan egorzhdan 2 years ago
DougGregor DougGregor requested a review from hborla hborla 2 years ago
DougGregor DougGregor requested a review from slavapestov slavapestov 2 years ago
DougGregor DougGregor requested a review from xedin xedin 2 years ago
DougGregor
DougGregor2 years ago

@swift-ci please smoke test

rxwei
rxwei approved these changes on 2023-04-03
DougGregor DougGregor merged f7e47975 into main 2 years ago
DougGregor DougGregor deleted the top-level-macro-lookup branch 2 years ago

Login to write a write a comment.

Login via GitHub

Assignees
No one assigned
Labels
Milestone