Skip to content

Commit 1399aeb

Browse files
committed
[TBDGen] Consider -enable-testing for default arg generator symbols.
Fixes rdar://problem/40736382.
1 parent 724d434 commit 1399aeb

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/TBDGen/TBDGen.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,15 @@ void TBDGenVisitor::visitAbstractFunctionDecl(AbstractFunctionDecl *AFD) {
131131
addSymbol(SILDeclRef(AFD).asForeign());
132132
}
133133

134-
if (!SwiftModule->getASTContext().isSwiftVersion3())
134+
auto publicDefaultArgGenerators =
135+
SwiftModule->getASTContext().isSwiftVersion3() ||
136+
SwiftModule->isTestingEnabled();
137+
if (!publicDefaultArgGenerators)
135138
return;
136139

137-
// In Swift 3, default arguments (of public functions) are public symbols,
138-
// as the default values are computed at the call site.
140+
// In Swift 3 (or under -enable-testing), default arguments (of public
141+
// functions) are public symbols, as the default values are computed at the
142+
// call site.
139143
auto index = 0;
140144
auto paramLists = AFD->getParameterLists();
141145
// Skip the first arguments, which contains Self (etc.), can't be defaulted,

test/TBD/function.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: %target-swift-frontend -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=all -swift-version 3 %s
22
// RUN: %target-swift-frontend -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=all -swift-version 4 %s
3+
// RUN: %target-swift-frontend -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=all -swift-version 3 %s -enable-testing
4+
// RUN: %target-swift-frontend -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=all -swift-version 4 %s -enable-testing
35

46
public func publicNoArgs() {}
57
public func publicSomeArgs(_: Int, x: Int) {}

0 commit comments

Comments
 (0)