Skip to content

Commit 1fc0799

Browse files
committed
TBDGen: omit witness table symbol for imported resilient protocols
For imported resilient protocols, we cannot directly emit witness table symbol when a local type conforms to them because initializing these protocols are required. rdar://60429448
1 parent 08c4e73 commit 1fc0799

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)