mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Macros] Don't visit macro-generated extensions in 'visitAuxiliaryDecls'.
Macro-generated extensions are hoisted to file scope, because extensions are not valid in nested scopes. Callers of 'visitAuxiliaryDecls' assume that the auxiliary decls are in the same decl context as the original, which is clearly not the case for extensions, and it leads to issues like visiting extension at the wrong time during SILGen. The extensions are already added to the top-level decls, so we don't need to visit them as auxiliary decls, and we can type-check macro-expanded decls at the end of visitation in TypeCheckDeclPrimary.
This commit is contained in:
@@ -4104,8 +4104,7 @@ void FileUnit::getTopLevelDeclsWithAuxiliaryDecls(
|
||||
getTopLevelDecls(nonExpandedDecls);
|
||||
for (auto *decl : nonExpandedDecls) {
|
||||
decl->visitAuxiliaryDecls([&](Decl *auxDecl) {
|
||||
if (!isa<ExtensionDecl>(auxDecl))
|
||||
results.push_back(auxDecl);
|
||||
results.push_back(auxDecl);
|
||||
});
|
||||
results.push_back(decl);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user