@@ -367,6 +367,8 @@ static ProtocolConformanceRef getBuiltinFunctionTypeConformance(
367367 if (isBitwiseCopyableFunctionType (functionType))
368368 return synthesizeConformance ();
369369 break ;
370+ case KnownProtocolKind::SendableMetatype:
371+ return synthesizeConformance ();
370372 default :
371373 break ;
372374 }
@@ -387,21 +389,22 @@ static ProtocolConformanceRef getBuiltinMetaTypeTypeConformance(
387389 case KnownProtocolKind::Sendable:
388390 // Metatypes are generally Sendable, but under StrictSendableMetatypes we
389391 // cannot assume that metatypes based on type parameters are Sendable.
392+ // Therefore, check for conformance to SendableMetatype.
390393 if (ctx.LangOpts .hasFeature (Feature::StrictSendableMetatypes)) {
391- Type instanceType = metatypeType-> getInstanceType ();
392-
393- // If the instance type is a type parameter, it is not necessarily
394- // Sendable. There will need to be a Sendable requirement.
395- if (instanceType-> isTypeParameter ())
396- break ;
397-
398- // If the instance type is an archetype or existential, check whether
399- // it conforms to Sendable.
400- // FIXME: If the requirement machine were to infer T.Type: Sendable
401- // from T: Sendable, we wouldn't need this for archetypes.
402- if (instanceType-> is <ArchetypeType>() ||
403- instanceType-> isAnyExistentialType ()) {
404- auto instanceConformance = lookupConformance ( instanceType, protocol );
394+ auto sendableMetatypeProto =
395+ ctx. getProtocol (KnownProtocolKind::SendableMetatype);
396+ if (sendableMetatypeProto) {
397+ Type instanceType = metatypeType-> getInstanceType ();
398+
399+ // If the instance type is a type parameter, it is not necessarily
400+ // Sendable. There will need to be a Sendable requirement.
401+ if (instanceType-> isTypeParameter ())
402+ break ;
403+
404+ // If the instance type conforms to SendableMetatype, then its
405+ // metatype is Sendable.
406+ auto instanceConformance = lookupConformance (
407+ instanceType, sendableMetatypeProto );
405408 if (instanceConformance.isInvalid () ||
406409 instanceConformance.hasMissingConformance ())
407410 break ;
@@ -414,6 +417,7 @@ static ProtocolConformanceRef getBuiltinMetaTypeTypeConformance(
414417 case KnownProtocolKind::Copyable:
415418 case KnownProtocolKind::Escapable:
416419 case KnownProtocolKind::BitwiseCopyable:
420+ case KnownProtocolKind::SendableMetatype:
417421 return ProtocolConformanceRef (
418422 ctx.getBuiltinConformance (type, protocol,
419423 BuiltinConformanceKind::Synthesized));
@@ -433,6 +437,7 @@ getBuiltinBuiltinTypeConformance(Type type, const BuiltinType *builtinType,
433437 if (auto kp = protocol->getKnownProtocolKind ()) {
434438 switch (*kp) {
435439 case KnownProtocolKind::Sendable:
440+ case KnownProtocolKind::SendableMetatype:
436441 case KnownProtocolKind::Copyable:
437442 case KnownProtocolKind::Escapable: {
438443 ASTContext &ctx = protocol->getASTContext ();
@@ -447,7 +452,8 @@ getBuiltinBuiltinTypeConformance(Type type, const BuiltinType *builtinType,
447452 break ;
448453 }
449454
450- // All other builtin types are Sendable, Copyable, and Escapable.
455+ // All other builtin types are Sendable, SendableMetatype, Copyable, and
456+ // Escapable.
451457 return ProtocolConformanceRef (
452458 ctx.getBuiltinConformance (type, protocol,
453459 BuiltinConformanceKind::Synthesized));
@@ -616,6 +622,13 @@ LookupConformanceInModuleRequest::evaluate(
616622 if (!nominal || isa<ProtocolDecl>(nominal))
617623 return ProtocolConformanceRef::forMissingOrInvalid (type, protocol);
618624
625+ // All nominal types implicitly conform to SendableMetatype.
626+ if (protocol->isSpecificProtocol (KnownProtocolKind::SendableMetatype)) {
627+ return ProtocolConformanceRef (
628+ ctx.getBuiltinConformance (type, protocol,
629+ BuiltinConformanceKind::Synthesized));
630+ }
631+
619632 // Expand conformances added by extension macros.
620633 //
621634 // FIXME: This expansion should only be done if the
0 commit comments