@@ -3855,7 +3855,7 @@ bool swift::checkSendableConformance(
38553855 return checkSendableInstanceStorage (nominal, conformanceDC, check);
38563856}
38573857
3858- NormalProtocolConformance *GetImplicitSendableRequest::evaluate (
3858+ ProtocolConformance *GetImplicitSendableRequest::evaluate (
38593859 Evaluator &evaluator, NominalTypeDecl *nominal) const {
38603860 // Protocols never get implicit Sendable conformances.
38613861 if (isa<ProtocolDecl>(nominal))
@@ -3900,14 +3900,14 @@ NormalProtocolConformance *GetImplicitSendableRequest::evaluate(
39003900 return nullptr ;
39013901 }
39023902
3903+ ASTContext &ctx = nominal->getASTContext ();
3904+ auto proto = ctx.getProtocol (KnownProtocolKind::Sendable);
3905+ if (!proto)
3906+ return nullptr ;
3907+
39033908 // Local function to form the implicit conformance.
39043909 auto formConformance = [&](const DeclAttribute *attrMakingUnavailable)
39053910 -> NormalProtocolConformance * {
3906- ASTContext &ctx = nominal->getASTContext ();
3907- auto proto = ctx.getProtocol (KnownProtocolKind::Sendable);
3908- if (!proto)
3909- return nullptr ;
3910-
39113911 DeclContext *conformanceDC = nominal;
39123912 if (attrMakingUnavailable) {
39133913 llvm::VersionTuple NoVersion;
@@ -3959,17 +3959,22 @@ NormalProtocolConformance *GetImplicitSendableRequest::evaluate(
39593959
39603960 // A non-protocol type with a global actor is implicitly Sendable.
39613961 if (nominal->getGlobalActorAttr ()) {
3962- // If this is a class, check the superclass. We won't infer Sendable
3963- // if the superclass is already Sendable, to avoid introducing redundant
3964- // conformances.
3962+ // If this is a class, check the superclass. If it's already Sendable,
3963+ // form an inherited conformance.
39653964 if (classDecl) {
39663965 if (Type superclass = classDecl->getSuperclass ()) {
39673966 auto classModule = classDecl->getParentModule ();
3968- if (TypeChecker::conformsToKnownProtocol (
3967+ if (auto inheritedConformance = TypeChecker::conformsToProtocol (
39693968 classDecl->mapTypeIntoContext (superclass),
3970- KnownProtocolKind::Sendable,
3971- classModule, /* allowMissing=*/ false ))
3972- return nullptr ;
3969+ proto, classModule, /* allowMissing=*/ false )) {
3970+ inheritedConformance = inheritedConformance
3971+ .mapConformanceOutOfContext ();
3972+ if (inheritedConformance.isConcrete ()) {
3973+ return ctx.getInheritedConformance (
3974+ nominal->getDeclaredInterfaceType (),
3975+ inheritedConformance.getConcrete ());
3976+ }
3977+ }
39733978 }
39743979 }
39753980
0 commit comments