@@ -707,10 +707,15 @@ namespace {
707707
708708 template <class G >
709709 void addParameter (const G &generator,
710- ParamSpecifier ownership = ParamSpecifier::Default) {
710+ ParamSpecifier ownership = ParamSpecifier::Default,
711+ bool isSending = false ) {
711712 Type gTyIface = generator.build (*this );
712713 auto flags = ParameterTypeFlags ().withOwnershipSpecifier (ownership);
713- InterfaceParams.emplace_back (gTyIface , Identifier (), flags);
714+ auto p = AnyFunctionType::Param (gTyIface , Identifier (), flags);
715+ if (isSending) {
716+ p = p.withFlags (p.getParameterFlags ().withSending (true ));
717+ }
718+ InterfaceParams.push_back (p);
714719 }
715720
716721 template <class G >
@@ -1540,18 +1545,20 @@ static ValueDecl *getCreateTask(ASTContext &ctx, Identifier id) {
15401545 return getBuiltinFunction (
15411546 ctx, id, _thin, _generics (_unrestricted, _conformsToDefaults (0 )),
15421547 _parameters (
1543- _label (" flags" , _swiftInt),
1544- _label (" initialSerialExecutor" , _defaulted (_optional (_executor), _nil)),
1545- _label (" taskGroup" , _defaulted (_optional (_rawPointer), _nil)),
1546- _label (" initialTaskExecutor" , _defaulted (_optional (_executor), _nil)),
1547- _label (" initialTaskExecutorConsuming" ,
1548+ _label (" flags" , _swiftInt),
1549+ _label (" initialSerialExecutor" ,
1550+ _defaulted (_optional (_executor), _nil)),
1551+ _label (" taskGroup" , _defaulted (_optional (_rawPointer), _nil)),
1552+ _label (" initialTaskExecutor" , _defaulted (_optional (_executor), _nil)),
1553+ _label (" initialTaskExecutorConsuming" ,
15481554 _defaulted (_consuming (_optional (_bincompatType (
15491555 /* if*/ taskExecutorIsAvailable,
15501556 _existential (_taskExecutor),
15511557 /* else*/ _executor))),
15521558 _nil)),
1553- _label (" operation" , _function (_async (_throws (_sendable (_thick))),
1554- _typeparam (0 ), _parameters ()))),
1559+ _label (" operation" ,
1560+ _sending (_function (_async (_throws (_thick)), _typeparam (0 ),
1561+ _parameters ())))),
15551562 _tuple (_nativeObject, _rawPointer));
15561563}
15571564
@@ -1562,18 +1569,19 @@ static ValueDecl *getCreateDiscardingTask(ASTContext &ctx, Identifier id) {
15621569 return getBuiltinFunction (
15631570 ctx, id, _thin,
15641571 _parameters (
1565- _label (" flags" , _swiftInt),
1566- _label (" initialSerialExecutor" , _defaulted (_optional (_executor), _nil)),
1567- _label (" taskGroup" , _defaulted (_optional (_rawPointer), _nil)),
1568- _label (" initialTaskExecutor" , _defaulted (_optional (_executor), _nil)),
1569- _label (" initialTaskExecutorConsuming" ,
1570- _defaulted (_consuming (_optional (_bincompatType (
1571- /* if*/ taskExecutorIsAvailable,
1572- _existential (_taskExecutor),
1573- /* else*/ _executor))),
1574- _nil)),
1575- _label (" operation" , _function (_async (_throws (_sendable (_thick))),
1576- _void, _parameters ()))),
1572+ _label (" flags" , _swiftInt),
1573+ _label (" initialSerialExecutor" ,
1574+ _defaulted (_optional (_executor), _nil)),
1575+ _label (" taskGroup" , _defaulted (_optional (_rawPointer), _nil)),
1576+ _label (" initialTaskExecutor" , _defaulted (_optional (_executor), _nil)),
1577+ _label (" initialTaskExecutorConsuming" ,
1578+ _defaulted (_consuming (_optional (_bincompatType (
1579+ /* if*/ taskExecutorIsAvailable,
1580+ _existential (_taskExecutor),
1581+ /* else*/ _executor))),
1582+ _nil)),
1583+ _label (" operation" , _sending (_function (_async (_throws (_thick)), _void,
1584+ _parameters ())))),
15771585 _tuple (_nativeObject, _rawPointer));
15781586}
15791587
@@ -1591,16 +1599,25 @@ static ValueDecl *getCreateAsyncTask(ASTContext &ctx, Identifier id,
15911599 if (withTaskExecutor) {
15921600 builder.addParameter (makeConcrete (ctx.TheExecutorType )); // executor
15931601 }
1594- auto extInfo = ASTExtInfoBuilder ().withAsync ().withThrows ()
1595- .withSendable (true ).build ();
1602+
1603+ bool areSendingArgsEnabled =
1604+ ctx.LangOpts .hasFeature (Feature::SendingArgsAndResults);
1605+
1606+ auto extInfo = ASTExtInfoBuilder ()
1607+ .withAsync ()
1608+ .withThrows ()
1609+ .withSendable (!areSendingArgsEnabled)
1610+ .build ();
15961611 Type operationResultType;
15971612 if (isDiscarding) {
15981613 operationResultType = TupleType::getEmpty (ctx); // ()
15991614 } else {
16001615 operationResultType = makeGenericParam ().build (builder); // <T>
16011616 }
1602- builder.addParameter (makeConcrete (
1603- FunctionType::get ({}, operationResultType, extInfo))); // operation
1617+ builder.addParameter (
1618+ makeConcrete (FunctionType::get ({}, operationResultType, extInfo)),
1619+ ParamSpecifier::Default,
1620+ areSendingArgsEnabled /* isSending*/ ); // operation
16041621 builder.setResult (makeConcrete (getAsyncTaskAndContextType (ctx)));
16051622 return builder.build (id);
16061623}
0 commit comments