Skip to content

Commit 21b9e80

Browse files
authored
Merge pull request swiftlang#30405 from nkcsgexi/omit-resilient-witness-table-tbd
TBDGen: omit witness table symbol for imported resilient protocols
2 parents 7fc48d8 + 1fc0799 commit 21b9e80

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/TBDGen/TBDGen.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,12 @@ void TBDGenVisitor::addConformances(DeclContext *DC) {
451451
if (!rootConformance) {
452452
continue;
453453
}
454-
455-
addSymbol(LinkEntity::forProtocolWitnessTable(rootConformance));
454+
// We cannot emit the witness table symbol if the protocol is imported from
455+
// another module and it's resilient, because initialization of that protocol
456+
// is necessary in this case
457+
if (!rootConformance->getProtocol()->isResilient(DC->getParentModule(),
458+
ResilienceExpansion::Maximal))
459+
addSymbol(LinkEntity::forProtocolWitnessTable(rootConformance));
456460
addSymbol(LinkEntity::forProtocolConformanceDescriptor(rootConformance));
457461

458462
// FIXME: the logic around visibility in extensions is confusing, and

test/TBD/omit-witness-table.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// REQUIRES: VENDOR=apple
2+
// RUN: %empty-directory(%t)
3+
// RUN: %target-swift-frontend -parse-as-library -module-name test -validate-tbd-against-ir=all %s -enable-library-evolution -emit-tbd -emit-tbd-path %t.result.tbd -tbd-is-installapi -parse-as-library -emit-ir -o/dev/null
4+
5+
public enum TestError : Error {
6+
case unsupportedVersion(Int)
7+
}

0 commit comments

Comments
 (0)