@@ -647,8 +647,7 @@ UNINTERESTING_FEATURE(GroupActorErrors)
647647
648648UNINTERESTING_FEATURE(TransferringArgsAndResults)
649649static bool usesFeatureSendingArgsAndResults(Decl *decl) {
650- auto functionTypeUsesSending = [](Decl *decl) {
651- return usesTypeMatching (decl, [](Type type) {
650+ auto isFunctionTypeWithSending = [](Type type) {
652651 auto fnType = type->getAs <AnyFunctionType>();
653652 if (!fnType)
654653 return false ;
@@ -660,15 +659,17 @@ static bool usesFeatureSendingArgsAndResults(Decl *decl) {
660659 [](AnyFunctionType::Param param) {
661660 return param.getParameterFlags ().isSending ();
662661 });
663- });
662+ };
663+ auto declUsesFunctionTypesThatUseSending = [&](Decl *decl) {
664+ return usesTypeMatching (decl, isFunctionTypeWithSending);
664665 };
665666
666667 if (auto *pd = dyn_cast<ParamDecl>(decl)) {
667668 if (pd->isSending ()) {
668669 return true ;
669670 }
670671
671- if (functionTypeUsesSending (pd))
672+ if (declUsesFunctionTypesThatUseSending (pd))
672673 return true ;
673674 }
674675
@@ -678,10 +679,20 @@ static bool usesFeatureSendingArgsAndResults(Decl *decl) {
678679 return usesFeatureSendingArgsAndResults (pd);
679680 }))
680681 return true ;
681- if (functionTypeUsesSending (decl))
682+ if (declUsesFunctionTypesThatUseSending (decl))
682683 return true ;
683684 }
684685
686+ // Check if we have a pattern binding decl for a function that has sending
687+ // parameters and results.
688+ if (auto *pbd = dyn_cast<PatternBindingDecl>(decl)) {
689+ for (auto index : range (pbd->getNumPatternEntries ())) {
690+ auto *pattern = pbd->getPattern (index);
691+ if (pattern->hasType () && isFunctionTypeWithSending (pattern->getType ()))
692+ return true ;
693+ }
694+ }
695+
685696 return false ;
686697}
687698
0 commit comments