Skip to content

Commit 24caf94

Browse files
authored
[TBDGen] Fix a deserialization crash in TBDGen
Fix a deserialization failure crash in `TBDGenVisitor`, where an internal protocol conformance with a project internal symbol witness for an `associatedtype` triggers a crash inside `addConformances` because the module containing the project internal symbol is not available. Fixes rdar://93983322
1 parent 05fca99 commit 24caf94

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

lib/TBDGen/TBDGen.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,10 @@ void TBDGenVisitor::addConformances(const IterableDeclContext *IDC) {
479479
for (auto conformance : IDC->getLocalConformances(
480480
ConformanceLookupKind::NonInherited)) {
481481
auto protocol = conformance->getProtocol();
482+
if (Opts.PublicSymbolsOnly &&
483+
getDeclLinkage(protocol) != FormalLinkage::PublicUnique)
484+
continue;
485+
482486
auto needsWTable =
483487
Lowering::TypeConverter::protocolRequiresWitnessTable(protocol);
484488
if (!needsWTable)

test/TBD/rdar93983322.swift

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// REQUIRES: OS=macosx
2+
// RUN: %empty-directory(%t)
3+
// RUN: mkdir -p %t/Modules
4+
// RUN: split-file %s %t
5+
6+
// Build the project internal module
7+
// RUN: %target-swift-frontend %t/ProjectInternal.swift \
8+
// RUN: -emit-module -module-name ProjectInternal \
9+
// RUN: -o %t/Modules/ProjectInternal.swiftmodule \
10+
// RUN: -disable-experimental-string-processing
11+
12+
// Build MyModule with search path to the project internal module
13+
// RUN: %target-swift-frontend %t/MyModule.swift \
14+
// RUN: -emit-module -module-name MyModule \
15+
// RUN: -o %t/Modules/MyModule.swiftmodule \
16+
// RUN: -I %t/Modules -disable-experimental-string-processing
17+
18+
// Remove the project internal module as it's not available to clients of MyModule
19+
// RUN: rm %t/Modules/ProjectInternal.swiftmodule
20+
21+
// Use swift-api-extract to load MyModule without ProjectInternal
22+
// RUN: %target-swift-api-extract -o - -pretty-print \
23+
// RUN: -module-name MyModule -I %t/Modules
24+
25+
//--- ProjectInternal.swift
26+
public class ProjectInternalClass {}
27+
28+
//--- MyModule.swift
29+
@_implementationOnly import ProjectInternal
30+
31+
public protocol PublicProtocol {}
32+
33+
extension ProjectInternalClass : PublicProtocol {}
34+
35+
internal protocol InternalProtocol {
36+
associatedtype T : PublicProtocol
37+
static var v : [T] { get }
38+
}
39+
40+
public class PublicClass {}
41+
42+
extension PublicClass : InternalProtocol {
43+
static let v : [ProjectInternalClass] = []
44+
}

0 commit comments

Comments
 (0)