Skip to content

Commit 051a6ab

Browse files
committed
Default argument generator functions are not dynamically replaceable for now
1 parent a2c6515 commit 051a6ab

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

lib/SIL/SILDeclRef.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,8 @@ static bool isDesignatedConstructorForClass(ValueDecl *decl) {
10381038
}
10391039

10401040
bool SILDeclRef::canBeDynamicReplacement() const {
1041-
if (kind == SILDeclRef::Kind::Destroyer)
1041+
if (kind == SILDeclRef::Kind::Destroyer ||
1042+
kind == SILDeclRef::Kind::DefaultArgGenerator)
10421043
return false;
10431044
if (kind == SILDeclRef::Kind::Initializer)
10441045
return isDesignatedConstructorForClass(getDecl());
@@ -1048,6 +1049,8 @@ bool SILDeclRef::canBeDynamicReplacement() const {
10481049
}
10491050

10501051
bool SILDeclRef::isDynamicallyReplaceable() const {
1052+
if (kind == SILDeclRef::Kind::DefaultArgGenerator)
1053+
return false;
10511054
if (isStoredPropertyInitializer())
10521055
return false;
10531056

lib/TBDGen/TBDGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ void TBDGenVisitor::visitAbstractFunctionDecl(AbstractFunctionDecl *AFD) {
214214
addSymbol(SILDeclRef(AFD).asForeign());
215215
}
216216

217-
auto publicDefaultArgGenerators = SwiftModule->isTestingEnabled();
217+
auto publicDefaultArgGenerators = SwiftModule->isTestingEnabled() ||
218+
SwiftModule->arePrivateImportsEnabled();
218219
if (!publicDefaultArgGenerators)
219220
return;
220221

test/SILGen/dynamically_replaceable.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,9 @@ func getsetX(_ x: Int) -> Int {
350350
globalX = x
351351
return globalX
352352
}
353+
354+
// CHECK-LABEL: sil hidden [ossa] @$s23dynamically_replaceable18funcWithDefaultArgyySSFfA_
355+
// CHECK-LABEL: sil hidden [dynamically_replacable] [ossa] @$s23dynamically_replaceable18funcWithDefaultArgyySSF
356+
dynamic func funcWithDefaultArg(_ arg : String = String("hello")) {
357+
print("hello")
358+
}

test/TBD/private_import.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing -enable-private-imports %s
2+
func funcWithDefaultArg(_ arg : String = String("hello")) {
3+
}

0 commit comments

Comments
 (0)