Skip to content

Commit c321b33

Browse files
committed
SIL: Fix crash with missing existential Sendable conformance
If a protocol does not inherit Sendable, we still say that the existential type is Sendable in Swift 5 mode. Make sure this doesn't crash the SIL specializer. Fixes #75728
1 parent de16ed8 commit c321b33

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

include/swift/SIL/SILCloner.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
235235
llvm::errs() << "\nsubstitution map:\n";
236236
Subs.dump(llvm::errs());
237237
llvm::errs() << "\n";
238+
llvm::errs() << "\ncomposed substitution map:\n";
239+
substSubs.dump(llvm::errs());
240+
llvm::errs() << "\n";
238241
abort();
239242
}
240243
}

lib/AST/ProtocolConformanceRef.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ ProtocolConformanceRef::subst(Type origType, InFlightSubstitution &IFS) const {
111111
// If the type is an existential, it must be self-conforming.
112112
if (substType->isExistentialType()) {
113113
auto optConformance =
114-
proto->getModuleContext()->lookupExistentialConformance(substType,
115-
proto);
114+
ModuleDecl::lookupConformance(substType, proto, /*allowMissing=*/true);
116115
if (optConformance)
117116
return optConformance;
118117

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-frontend -emit-sil %s -O -swift-version 5 | %FileCheck %s
2+
3+
public final class Class<T: Sendable> {
4+
@inline(never)
5+
public init() {}
6+
}
7+
8+
public protocol P {}
9+
10+
// CHECK-LABEL: sil @$s27specialize_missing_sendable6callerAA5ClassCyAA1P_pGyF : $@convention(thin) () -> @owned Class<any P> {
11+
public func caller() -> Class<any P> {
12+
// CHECK: function_ref @$s27specialize_missing_sendable5ClassCACyxGycfCAA1P_p_Tgm5 : $@convention(thin) () -> @owned Class<any P>
13+
// CHECK: return
14+
return Class<any P>()
15+
}

0 commit comments

Comments
 (0)