@@ -1709,6 +1709,18 @@ FunctionType *ConstraintSystem::adjustFunctionTypeForConcurrency(
17091709 return openType (type, replacements, locator);
17101710 });
17111711
1712+ if (Context.LangOpts .hasFeature (Feature::InferSendableFromCaptures)) {
1713+ if (auto *FD = dyn_cast<AbstractFunctionDecl>(decl)) {
1714+ auto *DC = FD->getDeclContext ();
1715+ // All global functions should be @Sendable
1716+ if (DC->isModuleScopeContext () &&
1717+ !adjustedTy->getExtInfo ().isSendable ()) {
1718+ adjustedTy =
1719+ adjustedTy->withExtInfo (adjustedTy->getExtInfo ().withSendable ());
1720+ }
1721+ }
1722+ }
1723+
17121724 return adjustedTy->castTo <FunctionType>();
17131725}
17141726
@@ -1800,14 +1812,6 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
18001812 auto numLabelsToRemove = getNumRemovedArgumentLabels (
18011813 funcDecl, /* isCurriedInstanceReference=*/ false , functionRefKind);
18021814
1803- if (Context.LangOpts .hasFeature (Feature::InferSendableFromCaptures)) {
1804- // All global functions should be @Sendable
1805- if (funcDecl->getDeclContext ()->isModuleScopeContext ()) {
1806- funcType =
1807- funcType->withExtInfo (funcType->getExtInfo ().withSendable ());
1808- }
1809- }
1810-
18111815 auto openedType = openFunctionType (funcType, locator, replacements,
18121816 funcDecl->getDeclContext ())
18131817 ->removeArgumentLabels (numLabelsToRemove);
0 commit comments