@@ -1709,6 +1709,18 @@ FunctionType *ConstraintSystem::adjustFunctionTypeForConcurrency(
1709
1709
return openType (type, replacements, locator);
1710
1710
});
1711
1711
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
+
1712
1724
return adjustedTy->castTo <FunctionType>();
1713
1725
}
1714
1726
@@ -1800,14 +1812,6 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
1800
1812
auto numLabelsToRemove = getNumRemovedArgumentLabels (
1801
1813
funcDecl, /* isCurriedInstanceReference=*/ false , functionRefKind);
1802
1814
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
-
1811
1815
auto openedType = openFunctionType (funcType, locator, replacements,
1812
1816
funcDecl->getDeclContext ())
1813
1817
->removeArgumentLabels (numLabelsToRemove);
0 commit comments