@@ -741,20 +741,45 @@ namespace {
741741 paramQualType->getPointeeType ().isConstQualified ())
742742 paramQualType = paramQualType->getPointeeType ();
743743
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+
744751 auto swiftParamTy = Impl.importTypeIgnoreIUO (
745752 paramQualType, paramImportKind, addImportDiagnostic,
746753 AllowNSUIntegerAsInt, Bridging, ImportTypeAttrs (), OTK_Optional);
747754 if (!swiftParamTy)
748755 return Type ();
749756
757+ ParameterTypeFlags flags;
758+ flags = flags.withSending (
759+ paramAttributes.contains (ImportTypeAttr::Sending));
760+
750761 // FIXME(https://github.com/apple/swift/issues/45134): If we were walking TypeLocs, we could actually get parameter names.
751762 // The probably doesn't matter outside of a FuncDecl, which we'll have
752763 // 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 ();
754779 }
755780
756781 // Form the function type.
757- return FunctionType::get (params, resultTy, FunctionType::ExtInfo () );
782+ return FunctionType::get (params, resultTy, extInfo );
758783 }
759784
760785 ImportResult
@@ -1729,17 +1754,21 @@ void swift::getConcurrencyAttrs(ASTContext &SwiftContext,
17291754 SwiftContext.LangOpts .hasFeature (Feature::SendableCompletionHandlers) &&
17301755 importKind == ImportTypeKind::CompletionHandlerParameter;
17311756 bool isNonSendable = false ;
1757+ bool isSending = false ;
17321758
17331759 // Consider only immediate attributes, don't look through the typerefs
17341760 // because they are imported separately.
17351761 findSwiftAttributes (type, [&](const clang::SwiftAttrAttr *attr) {
17361762 if (isMainActorAttr (attr)) {
17371763 isMainActor = true ;
17381764 isSendable = true ; // MainActor implies Sendable
1739- } else if (attr->getAttribute () == " @Sendable" )
1765+ } else if (attr->getAttribute () == " @Sendable" ) {
17401766 isSendable = true ;
1741- else if (attr->getAttribute () == " @_nonSendable" )
1767+ } else if (attr->getAttribute () == " @_nonSendable" ) {
17421768 isNonSendable = true ;
1769+ } else if (attr->getAttribute () == " sending" ) {
1770+ isSending = true ;
1771+ }
17431772 });
17441773
17451774 if (isMainActor)
@@ -1748,6 +1777,8 @@ void swift::getConcurrencyAttrs(ASTContext &SwiftContext,
17481777 attrs |= ImportTypeAttr::Sendable;
17491778 if (isNonSendable)
17501779 attrs -= ImportTypeAttr::Sendable;
1780+ if (isSending)
1781+ attrs |= ImportTypeAttr::Sending;
17511782}
17521783
17531784ImportedType ClangImporter::Implementation::importType (
0 commit comments