|
18 | 18 | #include "swift/AST/Attr.h"
|
19 | 19 | #include "swift/AST/AttrKind.h"
|
20 | 20 | #include "swift/AST/AutoDiff.h"
|
| 21 | +#include "swift/AST/ConformanceLookup.h" |
21 | 22 | #include "swift/AST/DiagnosticsSema.h"
|
22 | 23 | #include "swift/AST/DistributedDecl.h"
|
23 | 24 | #include "swift/AST/Expr.h"
|
@@ -957,16 +958,29 @@ ProtocolConformanceDeserializer::readNormalProtocolConformanceXRef(
|
957 | 958 | if (!module)
|
958 | 959 | module = MF.getAssociatedModule();
|
959 | 960 |
|
960 |
| - SmallVector<ProtocolConformance *, 2> conformances; |
961 |
| - nominal->lookupConformance(proto, conformances); |
962 | 961 | PrettyStackTraceModuleFile traceMsg(
|
963 | 962 | "If you're seeing a crash here, check that your SDK and dependencies "
|
964 | 963 | "are at least as new as the versions used to build", MF);
|
965 |
| - // This would normally be an assertion but it's more useful to print the |
966 |
| - // PrettyStackTrace here even in no-asserts builds. |
967 |
| - if (conformances.empty()) |
968 |
| - abort(); |
969 |
| - return conformances.front(); |
| 964 | + |
| 965 | + // Because Sendable conformances are currently inferred with |
| 966 | + // 'ImplicitKnownProtocolConformanceRequest' in swift::lookupConformance, |
| 967 | + // we may end up in a situation where we are deserializing such inferred |
| 968 | + // conformance but a lookup on the 'NominalDecl' will not succeed nor |
| 969 | + // will it run inference logic. For now, special-case 'Sendable' lookups |
| 970 | + // here. |
| 971 | + // TODO: Sink Sendable derivation into the conformance lookup table |
| 972 | + if (proto->isSpecificProtocol(KnownProtocolKind::Sendable)) { |
| 973 | + auto conformanceRef = lookupConformance(nominal->getDeclaredInterfaceType(), proto); |
| 974 | + if (!conformanceRef.isConcrete()) |
| 975 | + abort(); |
| 976 | + return conformanceRef.getConcrete(); |
| 977 | + } else { |
| 978 | + SmallVector<ProtocolConformance *, 2> conformances; |
| 979 | + nominal->lookupConformance(proto, conformances); |
| 980 | + if (conformances.empty()) |
| 981 | + abort(); |
| 982 | + return conformances.front(); |
| 983 | + } |
970 | 984 | }
|
971 | 985 |
|
972 | 986 | Expected<ProtocolConformance *>
|
|
0 commit comments