@@ -708,10 +708,15 @@ namespace {
708708
709709 template <class G >
710710 void addParameter (const G &generator,
711- ParamSpecifier ownership = ParamSpecifier::Default) {
711+ ParamSpecifier ownership = ParamSpecifier::Default,
712+ bool isSending = false ) {
712713 Type gTyIface = generator.build (*this );
713714 auto flags = ParameterTypeFlags ().withOwnershipSpecifier (ownership);
714- InterfaceParams.emplace_back (gTyIface , Identifier (), flags);
715+ auto p = AnyFunctionType::Param (gTyIface , Identifier (), flags);
716+ if (isSending) {
717+ p = p.withFlags (p.getParameterFlags ().withSending (true ));
718+ }
719+ InterfaceParams.push_back (p);
715720 }
716721
717722 template <class G >
@@ -1533,18 +1538,20 @@ static ValueDecl *getCreateTask(ASTContext &ctx, Identifier id) {
15331538 return getBuiltinFunction (
15341539 ctx, id, _thin, _generics (_unrestricted, _conformsToDefaults (0 )),
15351540 _parameters (
1536- _label (" flags" , _swiftInt),
1537- _label (" initialSerialExecutor" , _defaulted (_optional (_executor), _nil)),
1538- _label (" taskGroup" , _defaulted (_optional (_rawPointer), _nil)),
1539- _label (" initialTaskExecutor" , _defaulted (_optional (_executor), _nil)),
1540- _label (" initialTaskExecutorConsuming" ,
1541+ _label (" flags" , _swiftInt),
1542+ _label (" initialSerialExecutor" ,
1543+ _defaulted (_optional (_executor), _nil)),
1544+ _label (" taskGroup" , _defaulted (_optional (_rawPointer), _nil)),
1545+ _label (" initialTaskExecutor" , _defaulted (_optional (_executor), _nil)),
1546+ _label (" initialTaskExecutorConsuming" ,
15411547 _defaulted (_consuming (_optional (_bincompatType (
15421548 /* if*/ taskExecutorIsAvailable,
15431549 _existential (_taskExecutor),
15441550 /* else*/ _executor))),
15451551 _nil)),
1546- _label (" operation" , _function (_async (_throws (_sendable (_thick))),
1547- _typeparam (0 ), _parameters ()))),
1552+ _label (" operation" ,
1553+ _sending (_function (_async (_throws (_thick)), _typeparam (0 ),
1554+ _parameters ())))),
15481555 _tuple (_nativeObject, _rawPointer));
15491556}
15501557
@@ -1555,18 +1562,19 @@ static ValueDecl *getCreateDiscardingTask(ASTContext &ctx, Identifier id) {
15551562 return getBuiltinFunction (
15561563 ctx, id, _thin,
15571564 _parameters (
1558- _label (" flags" , _swiftInt),
1559- _label (" initialSerialExecutor" , _defaulted (_optional (_executor), _nil)),
1560- _label (" taskGroup" , _defaulted (_optional (_rawPointer), _nil)),
1561- _label (" initialTaskExecutor" , _defaulted (_optional (_executor), _nil)),
1562- _label (" initialTaskExecutorConsuming" ,
1563- _defaulted (_consuming (_optional (_bincompatType (
1564- /* if*/ taskExecutorIsAvailable,
1565- _existential (_taskExecutor),
1566- /* else*/ _executor))),
1567- _nil)),
1568- _label (" operation" , _function (_async (_throws (_sendable (_thick))),
1569- _void, _parameters ()))),
1565+ _label (" flags" , _swiftInt),
1566+ _label (" initialSerialExecutor" ,
1567+ _defaulted (_optional (_executor), _nil)),
1568+ _label (" taskGroup" , _defaulted (_optional (_rawPointer), _nil)),
1569+ _label (" initialTaskExecutor" , _defaulted (_optional (_executor), _nil)),
1570+ _label (" initialTaskExecutorConsuming" ,
1571+ _defaulted (_consuming (_optional (_bincompatType (
1572+ /* if*/ taskExecutorIsAvailable,
1573+ _existential (_taskExecutor),
1574+ /* else*/ _executor))),
1575+ _nil)),
1576+ _label (" operation" , _sending (_function (_async (_throws (_thick)), _void,
1577+ _parameters ())))),
15701578 _tuple (_nativeObject, _rawPointer));
15711579}
15721580
@@ -1584,16 +1592,25 @@ static ValueDecl *getCreateAsyncTask(ASTContext &ctx, Identifier id,
15841592 if (withTaskExecutor) {
15851593 builder.addParameter (makeConcrete (ctx.TheExecutorType )); // executor
15861594 }
1587- auto extInfo = ASTExtInfoBuilder ().withAsync ().withThrows ()
1588- .withSendable (true ).build ();
1595+
1596+ bool areSendingArgsEnabled =
1597+ ctx.LangOpts .hasFeature (Feature::SendingArgsAndResults);
1598+
1599+ auto extInfo = ASTExtInfoBuilder ()
1600+ .withAsync ()
1601+ .withThrows ()
1602+ .withSendable (!areSendingArgsEnabled)
1603+ .build ();
15891604 Type operationResultType;
15901605 if (isDiscarding) {
15911606 operationResultType = TupleType::getEmpty (ctx); // ()
15921607 } else {
15931608 operationResultType = makeGenericParam ().build (builder); // <T>
15941609 }
1595- builder.addParameter (makeConcrete (
1596- FunctionType::get ({}, operationResultType, extInfo))); // operation
1610+ builder.addParameter (
1611+ makeConcrete (FunctionType::get ({}, operationResultType, extInfo)),
1612+ ParamSpecifier::Default,
1613+ areSendingArgsEnabled /* isSending*/ ); // operation
15971614 builder.setResult (makeConcrete (getAsyncTaskAndContextType (ctx)));
15981615 return builder.build (id);
15991616}
0 commit comments