Skip to content

Commit 19f367c

Browse files
committed
Don't visit synthesized extensions twice.
Teach `getTopLevelDeclsWithAuxiliaryDecls` not to provide extension declarations, because those are covered by the synthesized file, which all clients need to walk anyway. Without this, we end up asserting in TBD generation about duplicate symbol visitation. Encountered while investigating rdar://108056018.
1 parent 73f1097 commit 19f367c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/AST/Module.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4072,7 +4072,8 @@ void FileUnit::getTopLevelDeclsWithAuxiliaryDecls(
40724072
getTopLevelDecls(nonExpandedDecls);
40734073
for (auto *decl : nonExpandedDecls) {
40744074
decl->visitAuxiliaryDecls([&](Decl *auxDecl) {
4075-
results.push_back(auxDecl);
4075+
if (!isa<ExtensionDecl>(auxDecl))
4076+
results.push_back(auxDecl);
40764077
});
40774078
results.push_back(decl);
40784079
}

test/Macros/macro_expand_conformances.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// RUN: %target-swift-frontend -swift-version 5 -typecheck -load-plugin-library %t/%target-library-name(MacroDefinition) %s -disable-availability-checking -dump-macro-expansions > %t/expansions-dump.txt 2>&1
66
// RUN: %FileCheck -check-prefix=CHECK-DUMP %s < %t/expansions-dump.txt
77
// RUN: %target-typecheck-verify-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) -module-name MacroUser -DTEST_DIAGNOSTICS -swift-version 5
8-
// RUN: %target-build-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) %s -o %t/main -module-name MacroUser -swift-version 5
8+
// RUN: %target-build-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) %s -o %t/main -module-name MacroUser -swift-version 5 -emit-tbd -emit-tbd-path %t/MacroUser.tbd
99
// RUN: %target-codesign %t/main
1010
// RUN: %target-run %t/main | %FileCheck %s
1111

0 commit comments

Comments
 (0)