@@ -707,10 +707,15 @@ namespace {
707
707
708
708
template <class G >
709
709
void addParameter (const G &generator,
710
- ParamSpecifier ownership = ParamSpecifier::Default) {
710
+ ParamSpecifier ownership = ParamSpecifier::Default,
711
+ bool isSending = false ) {
711
712
Type gTyIface = generator.build (*this );
712
713
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);
714
719
}
715
720
716
721
template <class G >
@@ -1540,18 +1545,20 @@ static ValueDecl *getCreateTask(ASTContext &ctx, Identifier id) {
1540
1545
return getBuiltinFunction (
1541
1546
ctx, id, _thin, _generics (_unrestricted, _conformsToDefaults (0 )),
1542
1547
_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" ,
1548
1554
_defaulted (_consuming (_optional (_bincompatType (
1549
1555
/* if*/ taskExecutorIsAvailable,
1550
1556
_existential (_taskExecutor),
1551
1557
/* else*/ _executor))),
1552
1558
_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 ())))),
1555
1562
_tuple (_nativeObject, _rawPointer));
1556
1563
}
1557
1564
@@ -1562,18 +1569,19 @@ static ValueDecl *getCreateDiscardingTask(ASTContext &ctx, Identifier id) {
1562
1569
return getBuiltinFunction (
1563
1570
ctx, id, _thin,
1564
1571
_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 ())))),
1577
1585
_tuple (_nativeObject, _rawPointer));
1578
1586
}
1579
1587
@@ -1591,16 +1599,25 @@ static ValueDecl *getCreateAsyncTask(ASTContext &ctx, Identifier id,
1591
1599
if (withTaskExecutor) {
1592
1600
builder.addParameter (makeConcrete (ctx.TheExecutorType )); // executor
1593
1601
}
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 ();
1596
1611
Type operationResultType;
1597
1612
if (isDiscarding) {
1598
1613
operationResultType = TupleType::getEmpty (ctx); // ()
1599
1614
} else {
1600
1615
operationResultType = makeGenericParam ().build (builder); // <T>
1601
1616
}
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
1604
1621
builder.setResult (makeConcrete (getAsyncTaskAndContextType (ctx)));
1605
1622
return builder.build (id);
1606
1623
}
0 commit comments