Skip to content

Commit e840d9a

Browse files
authored
Merge pull request #64916 from DougGregor/visit-aux-decls-of-class-members-twice-5.9
[Macros] Don't visit auxiliary decls of class members twice.
2 parents 5a59df7 + e04b7f9 commit e840d9a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,9 +1821,13 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
18211821

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

18281832
if (auto *Stats = getASTContext().Stats)
18291833
++Stats->getFrontendCounters().NumDeclsTypechecked;

test/Macros/macro_expand_peers.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ func useCompletionHandlerG(s: S, _ body: @escaping (String) -> Void) {
6767
}
6868
}
6969

70+
class C {
71+
@addCompletionHandler
72+
func f(a: Int, for b: String, _ value: Double) async -> String {
73+
return b
74+
}
75+
}
76+
77+
7078
@addCompletionHandler
7179
func f(a: Int, for b: String, _ value: Double) async -> String {
7280
return b

0 commit comments

Comments
 (0)