@@ -4922,7 +4922,8 @@ void ProtocolDecl::computeKnownProtocolKind() const {
4922
4922
auto module = getModuleContext ();
4923
4923
if (module != module ->getASTContext ().getStdlibModule () &&
4924
4924
!module ->getName ().is (" Foundation" ) &&
4925
- !module ->getName ().is (" _Differentiation" )) {
4925
+ !module ->getName ().is (" _Differentiation" ) &&
4926
+ !module ->getName ().is (" _Concurrency" )) {
4926
4927
const_cast <ProtocolDecl *>(this )->Bits .ProtocolDecl .KnownProtocol = 1 ;
4927
4928
return ;
4928
4929
}
@@ -4968,6 +4969,8 @@ Optional<KnownDerivableProtocolKind>
4968
4969
return KnownDerivableProtocolKind::AdditiveArithmetic;
4969
4970
case KnownProtocolKind::Differentiable:
4970
4971
return KnownDerivableProtocolKind::Differentiable;
4972
+ case KnownProtocolKind::Actor:
4973
+ return KnownDerivableProtocolKind::Actor;
4971
4974
default : return None;
4972
4975
}
4973
4976
}
@@ -7380,6 +7383,56 @@ bool FuncDecl::isMainTypeMainMethod() const {
7380
7383
getParameters ()->size () == 0 ;
7381
7384
}
7382
7385
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
+
7383
7436
ConstructorDecl::ConstructorDecl (DeclName Name, SourceLoc ConstructorLoc,
7384
7437
bool Failable, SourceLoc FailabilityLoc,
7385
7438
bool Throws,
0 commit comments