@@ -4922,7 +4922,8 @@ void ProtocolDecl::computeKnownProtocolKind() const {
49224922 auto module = getModuleContext ();
49234923 if (module != module ->getASTContext ().getStdlibModule () &&
49244924 !module ->getName ().is (" Foundation" ) &&
4925- !module ->getName ().is (" _Differentiation" )) {
4925+ !module ->getName ().is (" _Differentiation" ) &&
4926+ !module ->getName ().is (" _Concurrency" )) {
49264927 const_cast <ProtocolDecl *>(this )->Bits .ProtocolDecl .KnownProtocol = 1 ;
49274928 return ;
49284929 }
@@ -4968,6 +4969,8 @@ Optional<KnownDerivableProtocolKind>
49684969 return KnownDerivableProtocolKind::AdditiveArithmetic;
49694970 case KnownProtocolKind::Differentiable:
49704971 return KnownDerivableProtocolKind::Differentiable;
4972+ case KnownProtocolKind::Actor:
4973+ return KnownDerivableProtocolKind::Actor;
49714974 default : return None;
49724975 }
49734976}
@@ -7380,6 +7383,56 @@ bool FuncDecl::isMainTypeMainMethod() const {
73807383 getParameters ()->size () == 0 ;
73817384}
73827385
7386+ bool FuncDecl::isEnqueuePartialTaskName (ASTContext &ctx, DeclName name) {
7387+ if (name.isCompoundName () && name.getBaseName () == ctx.Id_enqueue ) {
7388+ auto argumentNames = name.getArgumentNames ();
7389+ return argumentNames.size () == 1 && argumentNames[0 ] == ctx.Id_partialTask ;
7390+ }
7391+
7392+ return false ;
7393+ }
7394+
7395+ bool FuncDecl::isActorEnqueuePartialTaskWitness () const {
7396+ if (!isEnqueuePartialTaskName (getASTContext (), getName ()))
7397+ return false ;
7398+
7399+ auto classDecl = getDeclContext ()->getSelfClassDecl ();
7400+ if (!classDecl)
7401+ return false ;
7402+
7403+ if (!classDecl->isActor ())
7404+ return false ;
7405+
7406+ ASTContext &ctx = getASTContext ();
7407+ auto actorProto = ctx.getProtocol (KnownProtocolKind::Actor);
7408+ if (!actorProto)
7409+ return false ;
7410+
7411+ FuncDecl *requirement = nullptr ;
7412+ for (auto protoMember : actorProto->getParsedMembers ()) {
7413+ if (auto protoFunc = dyn_cast<FuncDecl>(protoMember)) {
7414+ if (isEnqueuePartialTaskName (ctx, protoFunc->getName ())) {
7415+ requirement = protoFunc;
7416+ break ;
7417+ }
7418+ }
7419+ }
7420+
7421+ if (!requirement)
7422+ return false ;
7423+
7424+ SmallVector<ProtocolConformance *, 1 > conformances;
7425+ classDecl->lookupConformance (
7426+ classDecl->getModuleContext (), actorProto, conformances);
7427+ for (auto conformance : conformances) {
7428+ auto witness = conformance->getWitnessDecl (requirement);
7429+ if (witness == this )
7430+ return true ;
7431+ }
7432+
7433+ return false ;
7434+ }
7435+
73837436ConstructorDecl::ConstructorDecl (DeclName Name, SourceLoc ConstructorLoc,
73847437 bool Failable, SourceLoc FailabilityLoc,
73857438 bool Throws,
0 commit comments