@@ -1139,9 +1139,45 @@ ProtocolConformanceRef ModuleDecl::lookupConformance(Type type,
1139
1139
static ProtocolConformanceRef getBuiltinTupleTypeConformance (
1140
1140
Type type, const TupleType *tupleType, ProtocolDecl *protocol,
1141
1141
ModuleDecl *module ) {
1142
+ ASTContext &ctx = protocol->getASTContext ();
1143
+
1144
+ // This is the new code path.
1145
+ //
1146
+ // FIXME: Remove the Sendable stuff below.
1147
+ auto *tupleDecl = ctx.getBuiltinTupleDecl ();
1148
+
1149
+ // Find the (unspecialized) conformance.
1150
+ SmallVector<ProtocolConformance *, 2 > conformances;
1151
+ if (tupleDecl->lookupConformance (protocol, conformances)) {
1152
+ // If we have multiple conformances, first try to filter out any that are
1153
+ // unavailable on the current deployment target.
1154
+ //
1155
+ // FIXME: Conformance lookup should really depend on source location for
1156
+ // this to be 100% correct.
1157
+ if (conformances.size () > 1 ) {
1158
+ SmallVector<ProtocolConformance *, 2 > availableConformances;
1159
+
1160
+ for (auto *conformance : conformances) {
1161
+ if (conformance->getDeclContext ()->isAlwaysAvailableConformanceContext ())
1162
+ availableConformances.push_back (conformance);
1163
+ }
1164
+
1165
+ // Don't filter anything out if all conformances are unavailable.
1166
+ if (!availableConformances.empty ())
1167
+ std::swap (availableConformances, conformances);
1168
+ }
1169
+
1170
+ auto *conformance = cast<NormalProtocolConformance>(conformances.front ());
1171
+ auto subMap = type->getContextSubstitutionMap (module ,
1172
+ conformance->getDeclContext ());
1173
+
1174
+ // TODO: labels
1175
+ auto *specialized = ctx.getSpecializedConformance (type, conformance, subMap);
1176
+ return ProtocolConformanceRef (specialized);
1177
+ }
1178
+
1142
1179
// Tuple type are Sendable when all of their element types are Sendable.
1143
1180
if (protocol->isSpecificProtocol (KnownProtocolKind::Sendable)) {
1144
- ASTContext &ctx = protocol->getASTContext ();
1145
1181
1146
1182
// Create the pieces for a generic tuple type (T1, T2, ... TN) and a
1147
1183
// generic signature <T1, T2, ..., TN>.
0 commit comments