Skip to content

Commit e68882e

Browse files
committed
SILLinker: make sure to de-serialize base protocol witness tables in embedded mode
Fixes unresolved symbol linker errors or compiler crashes rdar://148538336
1 parent b850395 commit e68882e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/SIL/IR/Linker.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,10 @@ void SILLinkerVisitor::visitProtocolConformance(
342342
// reading in most conformances until we need them for devirtualization.
343343
// However, we *must* pull in shared clang-importer-derived conformances
344344
// we potentially use, since we may not otherwise have a local definition.
345-
if (mustDeserializeProtocolConformance(Mod, c))
345+
if ((isEmbedded && referencedFromInitExistential) ||
346+
mustDeserializeProtocolConformance(Mod, c)) {
346347
visitProtocolConformance(c, referencedFromInitExistential);
348+
}
347349
};
348350

349351
// For each entry in the witness table...

test/embedded/existential-class-bound8.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99

1010
// BEGIN MyModule.swift
1111

12-
public protocol ClassBound: AnyObject {
12+
public protocol Base: AnyObject {
13+
func bar()
14+
}
15+
16+
public protocol ClassBound: Base {
1317
func foo()
1418
}
1519

@@ -18,6 +22,7 @@ class MyGenericClass<T> {
1822
init(typ: String) { self.typ = typ }
1923
}
2024
extension MyGenericClass: ClassBound {
25+
func bar() { print("MyGenericClass<\(typ)>.bar()") }
2126
func foo() { print("MyGenericClass<\(typ)>.foo()") }
2227
}
2328

@@ -32,3 +37,5 @@ import MyModule
3237
var arr: [any ClassBound] = [factory()]
3338
arr[0].foo()
3439
// CHECK: MyGenericClass<String>.foo()
40+
arr[0].foo()
41+
// CHECK: MyGenericClass<String>.bar()

0 commit comments

Comments
 (0)