Skip to content

[Macros] Don't visit auxiliary decls of class members twice. #64915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/Sema/TypeCheckDeclPrimary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1821,9 +1821,13 @@ class DeclChecker : public DeclVisitor<DeclChecker> {

void visit(Decl *decl) {
// Visit auxiliary decls first.
decl->visitAuxiliaryDecls([&](Decl *auxiliaryDecl) {
this->visit(auxiliaryDecl);
});
// We don't do this for members of classes because it happens as part of
// visiting their ABI members.
if (!isa<ClassDecl>(decl->getDeclContext())) {
decl->visitAuxiliaryDecls([&](Decl *auxiliaryDecl) {
this->visit(auxiliaryDecl);
});
}

if (auto *Stats = getASTContext().Stats)
++Stats->getFrontendCounters().NumDeclsTypechecked;
Expand Down
8 changes: 8 additions & 0 deletions test/Macros/macro_expand_peers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ func useCompletionHandlerG(s: S, _ body: @escaping (String) -> Void) {
}
}

class C {
@addCompletionHandler
func f(a: Int, for b: String, _ value: Double) async -> String {
return b
}
}


@addCompletionHandler
func f(a: Int, for b: String, _ value: Double) async -> String {
return b
Expand Down