@@ -741,20 +741,45 @@ namespace {
741
741
paramQualType->getPointeeType ().isConstQualified ())
742
742
paramQualType = paramQualType->getPointeeType ();
743
743
744
+ // Mark any `sending` parameters if need be.
745
+ ImportTypeAttrs paramAttributes;
746
+ if (Impl.SwiftContext .LangOpts .hasFeature (Feature::SendingArgsAndResults)) {
747
+ getConcurrencyAttrs (Impl.SwiftContext , ImportTypeKind::Parameter,
748
+ paramAttributes, paramQualType);
749
+ }
750
+
744
751
auto swiftParamTy = Impl.importTypeIgnoreIUO (
745
752
paramQualType, paramImportKind, addImportDiagnostic,
746
753
AllowNSUIntegerAsInt, Bridging, ImportTypeAttrs (), OTK_Optional);
747
754
if (!swiftParamTy)
748
755
return Type ();
749
756
757
+ ParameterTypeFlags flags;
758
+ flags = flags.withSending (
759
+ paramAttributes.contains (ImportTypeAttr::Sending));
760
+
750
761
// FIXME(https://github.com/apple/swift/issues/45134): If we were walking TypeLocs, we could actually get parameter names.
751
762
// The probably doesn't matter outside of a FuncDecl, which we'll have
752
763
// to special-case, but it's an interesting bit of data loss.
753
- params.push_back (FunctionType::Param (swiftParamTy));
764
+ params.emplace_back (swiftParamTy, Identifier (), flags);
765
+ }
766
+
767
+ // Mark any `sending` result types if need be.
768
+ auto extInfo = FunctionType::ExtInfo ();
769
+ ImportTypeAttrs resultAttributes;
770
+ if (Impl.SwiftContext .LangOpts .hasFeature (Feature::SendingArgsAndResults)) {
771
+ getConcurrencyAttrs (Impl.SwiftContext , ImportTypeKind::Result,
772
+ resultAttributes, type->getReturnType ());
773
+
774
+ const bool sending = resultAttributes.contains (ImportTypeAttr::Sending);
775
+ extInfo = FunctionType::ExtInfo ()
776
+ .intoBuilder ()
777
+ .withSendingResult (sending)
778
+ .build ();
754
779
}
755
780
756
781
// Form the function type.
757
- return FunctionType::get (params, resultTy, FunctionType::ExtInfo () );
782
+ return FunctionType::get (params, resultTy, extInfo );
758
783
}
759
784
760
785
ImportResult
@@ -1729,17 +1754,21 @@ void swift::getConcurrencyAttrs(ASTContext &SwiftContext,
1729
1754
SwiftContext.LangOpts .hasFeature (Feature::SendableCompletionHandlers) &&
1730
1755
importKind == ImportTypeKind::CompletionHandlerParameter;
1731
1756
bool isNonSendable = false ;
1757
+ bool isSending = false ;
1732
1758
1733
1759
// Consider only immediate attributes, don't look through the typerefs
1734
1760
// because they are imported separately.
1735
1761
findSwiftAttributes (type, [&](const clang::SwiftAttrAttr *attr) {
1736
1762
if (isMainActorAttr (attr)) {
1737
1763
isMainActor = true ;
1738
1764
isSendable = true ; // MainActor implies Sendable
1739
- } else if (attr->getAttribute () == " @Sendable" )
1765
+ } else if (attr->getAttribute () == " @Sendable" ) {
1740
1766
isSendable = true ;
1741
- else if (attr->getAttribute () == " @_nonSendable" )
1767
+ } else if (attr->getAttribute () == " @_nonSendable" ) {
1742
1768
isNonSendable = true ;
1769
+ } else if (attr->getAttribute () == " sending" ) {
1770
+ isSending = true ;
1771
+ }
1743
1772
});
1744
1773
1745
1774
if (isMainActor)
@@ -1748,6 +1777,8 @@ void swift::getConcurrencyAttrs(ASTContext &SwiftContext,
1748
1777
attrs |= ImportTypeAttr::Sendable;
1749
1778
if (isNonSendable)
1750
1779
attrs -= ImportTypeAttr::Sendable;
1780
+ if (isSending)
1781
+ attrs |= ImportTypeAttr::Sending;
1751
1782
}
1752
1783
1753
1784
ImportedType ClangImporter::Implementation::importType (
0 commit comments