@@ -2443,11 +2443,30 @@ ImportedType ClangImporter::Implementation::importFunctionParamsAndReturnType(
24432443 return {swiftResultTy, importedType.isImplicitlyUnwrapped ()};
24442444}
24452445
2446+ static bool isParameterContextGlobalActorIsolated (DeclContext *dc,
2447+ const clang::Decl *parent) {
2448+ if (getActorIsolationOfContext (dc).isGlobalActor ())
2449+ return true ;
2450+
2451+ if (!parent->hasAttrs ())
2452+ return false ;
2453+
2454+ for (const auto *attr : parent->getAttrs ()) {
2455+ if (auto swiftAttr = dyn_cast<clang::SwiftAttrAttr>(attr)) {
2456+ if (isMainActorAttr (swiftAttr))
2457+ return true ;
2458+ }
2459+ }
2460+
2461+ return false ;
2462+ }
2463+
24462464std::optional<ClangImporter::Implementation::ImportParameterTypeResult>
24472465ClangImporter::Implementation::importParameterType (
2448- const clang::ParmVarDecl *param, OptionalTypeKind optionalityOfParam,
2449- bool allowNSUIntegerAsInt, bool isNSDictionarySubscriptGetter,
2450- bool paramIsError, bool paramIsCompletionHandler,
2466+ DeclContext *dc, const clang::Decl *parent, const clang::ParmVarDecl *param,
2467+ OptionalTypeKind optionalityOfParam, bool allowNSUIntegerAsInt,
2468+ bool isNSDictionarySubscriptGetter, bool paramIsError,
2469+ bool paramIsCompletionHandler,
24512470 std::optional<unsigned > completionHandlerErrorParamIndex,
24522471 ArrayRef<GenericTypeParamDecl *> genericParams,
24532472 llvm::function_ref<void (Diagnostic &&)> addImportDiagnosticFn) {
@@ -2466,7 +2485,8 @@ ClangImporter::Implementation::importParameterType(
24662485
24672486 if (SwiftContext.LangOpts .hasFeature (Feature::SendableCompletionHandlers) &&
24682487 paramIsCompletionHandler) {
2469- attrs |= ImportTypeAttr::DefaultsToSendable;
2488+ if (!isParameterContextGlobalActorIsolated (dc, parent))
2489+ attrs |= ImportTypeAttr::DefaultsToSendable;
24702490 }
24712491
24722492 if (auto optionSetEnum = importer::findOptionSetEnum (paramTy, *this )) {
@@ -2743,13 +2763,13 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
27432763
27442764 ImportDiagnosticAdder paramAddDiag (*this , clangDecl, param->getLocation ());
27452765
2746- auto swiftParamTyOpt =
2747- importParameterType ( param, optionalityOfParam, allowNSUIntegerAsInt,
2748- /* isNSDictionarySubscriptGetter=*/ false ,
2749- /* paramIsError=*/ false ,
2750- /* paramIsCompletionHandler=*/ false ,
2751- /* completionHandlerErrorParamIndex=*/ std::nullopt ,
2752- genericParams, paramAddDiag);
2766+ auto swiftParamTyOpt = importParameterType (
2767+ dc, clangDecl, param, optionalityOfParam, allowNSUIntegerAsInt,
2768+ /* isNSDictionarySubscriptGetter=*/ false ,
2769+ /* paramIsError=*/ false ,
2770+ /* paramIsCompletionHandler=*/ false ,
2771+ /* completionHandlerErrorParamIndex=*/ std::nullopt , genericParams ,
2772+ paramAddDiag);
27532773 if (!swiftParamTyOpt) {
27542774 addImportDiagnostic (param,
27552775 Diagnostic (diag::parameter_type_not_imported, param),
@@ -3301,7 +3321,8 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
33013321 ImportDiagnosticAdder paramAddDiag (*this , clangDecl, param->getLocation ());
33023322
33033323 auto swiftParamTyOpt = importParameterType (
3304- param, optionalityOfParam, allowNSUIntegerAsIntInParam,
3324+ origDC, clangDecl, param, optionalityOfParam,
3325+ allowNSUIntegerAsIntInParam,
33053326 kind == SpecialMethodKind::NSDictionarySubscriptGetter, paramIsError,
33063327 paramIsCompletionHandler, completionHandlerErrorParamIndex,
33073328 ArrayRef<GenericTypeParamDecl *>(), paramAddDiag);
0 commit comments