@@ -2443,11 +2443,30 @@ ImportedType ClangImporter::Implementation::importFunctionParamsAndReturnType(
2443
2443
return {swiftResultTy, importedType.isImplicitlyUnwrapped ()};
2444
2444
}
2445
2445
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
+
2446
2464
std::optional<ClangImporter::Implementation::ImportParameterTypeResult>
2447
2465
ClangImporter::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,
2451
2470
std::optional<unsigned > completionHandlerErrorParamIndex,
2452
2471
ArrayRef<GenericTypeParamDecl *> genericParams,
2453
2472
llvm::function_ref<void (Diagnostic &&)> addImportDiagnosticFn) {
@@ -2466,7 +2485,8 @@ ClangImporter::Implementation::importParameterType(
2466
2485
2467
2486
if (SwiftContext.LangOpts .hasFeature (Feature::SendableCompletionHandlers) &&
2468
2487
paramIsCompletionHandler) {
2469
- attrs |= ImportTypeAttr::DefaultsToSendable;
2488
+ if (!isParameterContextGlobalActorIsolated (dc, parent))
2489
+ attrs |= ImportTypeAttr::DefaultsToSendable;
2470
2490
}
2471
2491
2472
2492
if (auto optionSetEnum = importer::findOptionSetEnum (paramTy, *this )) {
@@ -2743,13 +2763,13 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
2743
2763
2744
2764
ImportDiagnosticAdder paramAddDiag (*this , clangDecl, param->getLocation ());
2745
2765
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);
2753
2773
if (!swiftParamTyOpt) {
2754
2774
addImportDiagnostic (param,
2755
2775
Diagnostic (diag::parameter_type_not_imported, param),
@@ -3301,7 +3321,8 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
3301
3321
ImportDiagnosticAdder paramAddDiag (*this , clangDecl, param->getLocation ());
3302
3322
3303
3323
auto swiftParamTyOpt = importParameterType (
3304
- param, optionalityOfParam, allowNSUIntegerAsIntInParam,
3324
+ origDC, clangDecl, param, optionalityOfParam,
3325
+ allowNSUIntegerAsIntInParam,
3305
3326
kind == SpecialMethodKind::NSDictionarySubscriptGetter, paramIsError,
3306
3327
paramIsCompletionHandler, completionHandlerErrorParamIndex,
3307
3328
ArrayRef<GenericTypeParamDecl *>(), paramAddDiag);
0 commit comments