@@ -726,20 +726,45 @@ namespace {
726726 paramQualType->getPointeeType ().isConstQualified ())
727727 paramQualType = paramQualType->getPointeeType ();
728728
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+
729736 auto swiftParamTy = Impl.importTypeIgnoreIUO (
730737 paramQualType, paramImportKind, addImportDiagnostic,
731738 AllowNSUIntegerAsInt, Bridging, ImportTypeAttrs (), OTK_Optional);
732739 if (!swiftParamTy)
733740 return Type ();
734741
742+ ParameterTypeFlags flags;
743+ flags = flags.withSending (
744+ paramAttributes.contains (ImportTypeAttr::Sending));
745+
735746 // FIXME(https://github.com/apple/swift/issues/45134): If we were walking TypeLocs, we could actually get parameter names.
736747 // The probably doesn't matter outside of a FuncDecl, which we'll have
737748 // 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 ();
739764 }
740765
741766 // Form the function type.
742- return FunctionType::get (params, resultTy, FunctionType::ExtInfo () );
767+ return FunctionType::get (params, resultTy, extInfo );
743768 }
744769
745770 ImportResult
@@ -1714,17 +1739,21 @@ void swift::getConcurrencyAttrs(ASTContext &SwiftContext,
17141739 SwiftContext.LangOpts .hasFeature (Feature::SendableCompletionHandlers) &&
17151740 importKind == ImportTypeKind::CompletionHandlerParameter;
17161741 bool isNonSendable = false ;
1742+ bool isSending = false ;
17171743
17181744 // Consider only immediate attributes, don't look through the typerefs
17191745 // because they are imported separately.
17201746 findSwiftAttributes (type, [&](const clang::SwiftAttrAttr *attr) {
17211747 if (isMainActorAttr (attr)) {
17221748 isMainActor = true ;
17231749 isSendable = true ; // MainActor implies Sendable
1724- } else if (attr->getAttribute () == " @Sendable" )
1750+ } else if (attr->getAttribute () == " @Sendable" ) {
17251751 isSendable = true ;
1726- else if (attr->getAttribute () == " @_nonSendable" )
1752+ } else if (attr->getAttribute () == " @_nonSendable" ) {
17271753 isNonSendable = true ;
1754+ } else if (attr->getAttribute () == " sending" ) {
1755+ isSending = true ;
1756+ }
17281757 });
17291758
17301759 if (isMainActor)
@@ -1733,6 +1762,8 @@ void swift::getConcurrencyAttrs(ASTContext &SwiftContext,
17331762 attrs |= ImportTypeAttr::Sendable;
17341763 if (isNonSendable)
17351764 attrs -= ImportTypeAttr::Sendable;
1765+ if (isSending)
1766+ attrs |= ImportTypeAttr::Sending;
17361767}
17371768
17381769ImportedType ClangImporter::Implementation::importType (
0 commit comments