@@ -726,20 +726,45 @@ namespace {
726
726
paramQualType->getPointeeType ().isConstQualified ())
727
727
paramQualType = paramQualType->getPointeeType ();
728
728
729
+ // Mark any `sending` parameters if need be.
730
+ ImportTypeAttrs paramAttributes;
731
+ if (Impl.SwiftContext .LangOpts .hasFeature (Feature::SendingArgsAndResults)) {
732
+ getConcurrencyAttrs (Impl.SwiftContext , ImportTypeKind::Parameter,
733
+ paramAttributes, paramQualType);
734
+ }
735
+
729
736
auto swiftParamTy = Impl.importTypeIgnoreIUO (
730
737
paramQualType, paramImportKind, addImportDiagnostic,
731
738
AllowNSUIntegerAsInt, Bridging, ImportTypeAttrs (), OTK_Optional);
732
739
if (!swiftParamTy)
733
740
return Type ();
734
741
742
+ ParameterTypeFlags flags;
743
+ flags = flags.withSending (
744
+ paramAttributes.contains (ImportTypeAttr::Sending));
745
+
735
746
// FIXME(https://github.com/apple/swift/issues/45134): If we were walking TypeLocs, we could actually get parameter names.
736
747
// The probably doesn't matter outside of a FuncDecl, which we'll have
737
748
// to special-case, but it's an interesting bit of data loss.
738
- params.push_back (FunctionType::Param (swiftParamTy));
749
+ params.emplace_back (swiftParamTy, Identifier (), flags);
750
+ }
751
+
752
+ // Mark any `sending` result types if need be.
753
+ auto extInfo = FunctionType::ExtInfo ();
754
+ ImportTypeAttrs resultAttributes;
755
+ if (Impl.SwiftContext .LangOpts .hasFeature (Feature::SendingArgsAndResults)) {
756
+ getConcurrencyAttrs (Impl.SwiftContext , ImportTypeKind::Result,
757
+ resultAttributes, type->getReturnType ());
758
+
759
+ const bool sending = resultAttributes.contains (ImportTypeAttr::Sending);
760
+ extInfo = FunctionType::ExtInfo ()
761
+ .intoBuilder ()
762
+ .withSendingResult (sending)
763
+ .build ();
739
764
}
740
765
741
766
// Form the function type.
742
- return FunctionType::get (params, resultTy, FunctionType::ExtInfo () );
767
+ return FunctionType::get (params, resultTy, extInfo );
743
768
}
744
769
745
770
ImportResult
@@ -1714,17 +1739,21 @@ void swift::getConcurrencyAttrs(ASTContext &SwiftContext,
1714
1739
SwiftContext.LangOpts .hasFeature (Feature::SendableCompletionHandlers) &&
1715
1740
importKind == ImportTypeKind::CompletionHandlerParameter;
1716
1741
bool isNonSendable = false ;
1742
+ bool isSending = false ;
1717
1743
1718
1744
// Consider only immediate attributes, don't look through the typerefs
1719
1745
// because they are imported separately.
1720
1746
findSwiftAttributes (type, [&](const clang::SwiftAttrAttr *attr) {
1721
1747
if (isMainActorAttr (attr)) {
1722
1748
isMainActor = true ;
1723
1749
isSendable = true ; // MainActor implies Sendable
1724
- } else if (attr->getAttribute () == " @Sendable" )
1750
+ } else if (attr->getAttribute () == " @Sendable" ) {
1725
1751
isSendable = true ;
1726
- else if (attr->getAttribute () == " @_nonSendable" )
1752
+ } else if (attr->getAttribute () == " @_nonSendable" ) {
1727
1753
isNonSendable = true ;
1754
+ } else if (attr->getAttribute () == " sending" ) {
1755
+ isSending = true ;
1756
+ }
1728
1757
});
1729
1758
1730
1759
if (isMainActor)
@@ -1733,6 +1762,8 @@ void swift::getConcurrencyAttrs(ASTContext &SwiftContext,
1733
1762
attrs |= ImportTypeAttr::Sendable;
1734
1763
if (isNonSendable)
1735
1764
attrs -= ImportTypeAttr::Sendable;
1765
+ if (isSending)
1766
+ attrs |= ImportTypeAttr::Sending;
1736
1767
}
1737
1768
1738
1769
ImportedType ClangImporter::Implementation::importType (
0 commit comments