@@ -6296,10 +6296,44 @@ BuiltinTupleDecl *ASTContext::getBuiltinTupleDecl() {
6296
6296
if (result)
6297
6297
return result;
6298
6298
6299
- result = new (*this ) BuiltinTupleDecl (Id_TheTupleType,
6300
- TheBuiltinModule->getFiles ()[0 ]);
6299
+ auto *dc = TheBuiltinModule->getFiles ()[0 ];
6300
+
6301
+ result = new (*this ) BuiltinTupleDecl (Id_TheTupleType, dc);
6301
6302
result->setAccess (AccessLevel::Public);
6302
6303
6304
+ // Cook up conditional conformances to Sendable and Copyable.
6305
+ auto buildFakeExtension = [&](ProtocolDecl *proto) {
6306
+ auto protoTy = proto->getDeclaredInterfaceType ();
6307
+
6308
+ // extension Builtin.TheTupleType: P { ... }
6309
+ SmallVector<InheritedEntry, 1 > inherited;
6310
+ inherited.emplace_back (TypeLoc::withoutLoc (protoTy));
6311
+ auto *ext = ExtensionDecl::create (*this , SourceLoc (), nullptr ,
6312
+ AllocateCopy (inherited),
6313
+ dc, nullptr );
6314
+
6315
+ // <each T where repeat each T: P>
6316
+ auto genericSig = result->getGenericSignature ();
6317
+ auto params = genericSig.getGenericParams ();
6318
+ assert (params.size () == 1 );
6319
+ Requirement req (RequirementKind::Conformance, params[0 ], protoTy);
6320
+ genericSig = GenericSignature::get (params, req);
6321
+ ext->setGenericSignature (genericSig);
6322
+
6323
+ // Bind the extension.
6324
+ evaluator.cacheOutput (ExtendedTypeRequest{ext},
6325
+ result->getDeclaredInterfaceType ());
6326
+ ext->setExtendedNominal (result);
6327
+
6328
+ result->addExtension (ext);
6329
+ };
6330
+
6331
+ if (auto *proto = getProtocol (KnownProtocolKind::Sendable))
6332
+ buildFakeExtension (proto);
6333
+
6334
+ if (auto *proto = getProtocol (KnownProtocolKind::Copyable))
6335
+ buildFakeExtension (proto);
6336
+
6303
6337
return result;
6304
6338
}
6305
6339
0 commit comments