@@ -2421,11 +2421,30 @@ ImportedType ClangImporter::Implementation::importFunctionParamsAndReturnType(
2421
2421
return {swiftResultTy, importedType.isImplicitlyUnwrapped ()};
2422
2422
}
2423
2423
2424
+ static bool isParameterContextGlobalActorIsolated (DeclContext *dc,
2425
+ const clang::Decl *parent) {
2426
+ if (getActorIsolationOfContext (dc).isGlobalActor ())
2427
+ return true ;
2428
+
2429
+ if (!parent->hasAttrs ())
2430
+ return false ;
2431
+
2432
+ for (const auto *attr : parent->getAttrs ()) {
2433
+ if (auto swiftAttr = dyn_cast<clang::SwiftAttrAttr>(attr)) {
2434
+ if (isMainActorAttr (swiftAttr))
2435
+ return true ;
2436
+ }
2437
+ }
2438
+
2439
+ return false ;
2440
+ }
2441
+
2424
2442
std::optional<ClangImporter::Implementation::ImportParameterTypeResult>
2425
2443
ClangImporter::Implementation::importParameterType (
2426
- const clang::ParmVarDecl *param, OptionalTypeKind optionalityOfParam,
2427
- bool allowNSUIntegerAsInt, bool isNSDictionarySubscriptGetter,
2428
- bool paramIsError, bool paramIsCompletionHandler,
2444
+ DeclContext *dc, const clang::Decl *parent, const clang::ParmVarDecl *param,
2445
+ OptionalTypeKind optionalityOfParam, bool allowNSUIntegerAsInt,
2446
+ bool isNSDictionarySubscriptGetter, bool paramIsError,
2447
+ bool paramIsCompletionHandler,
2429
2448
std::optional<unsigned > completionHandlerErrorParamIndex,
2430
2449
ArrayRef<GenericTypeParamDecl *> genericParams,
2431
2450
llvm::function_ref<void (Diagnostic &&)> addImportDiagnosticFn) {
@@ -2445,7 +2464,8 @@ ClangImporter::Implementation::importParameterType(
2445
2464
2446
2465
if (SwiftContext.LangOpts .hasFeature (Feature::SendableCompletionHandlers) &&
2447
2466
paramIsCompletionHandler) {
2448
- attrs |= ImportTypeAttr::DefaultsToSendable;
2467
+ if (!isParameterContextGlobalActorIsolated (dc, parent))
2468
+ attrs |= ImportTypeAttr::DefaultsToSendable;
2449
2469
}
2450
2470
2451
2471
if (auto optionSetEnum = importer::findOptionSetEnum (paramTy, *this )) {
@@ -2722,13 +2742,13 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
2722
2742
2723
2743
ImportDiagnosticAdder paramAddDiag (*this , clangDecl, param->getLocation ());
2724
2744
2725
- auto swiftParamTyOpt =
2726
- importParameterType ( param, optionalityOfParam, allowNSUIntegerAsInt,
2727
- /* isNSDictionarySubscriptGetter=*/ false ,
2728
- /* paramIsError=*/ false ,
2729
- /* paramIsCompletionHandler=*/ false ,
2730
- /* completionHandlerErrorParamIndex=*/ std::nullopt,
2731
- genericParams, paramAddDiag);
2745
+ auto swiftParamTyOpt = importParameterType (
2746
+ dc, clangDecl, param, optionalityOfParam, allowNSUIntegerAsInt,
2747
+ /* isNSDictionarySubscriptGetter=*/ false ,
2748
+ /* paramIsError=*/ false ,
2749
+ /* paramIsCompletionHandler=*/ false ,
2750
+ /* completionHandlerErrorParamIndex=*/ std::nullopt, genericParams ,
2751
+ paramAddDiag);
2732
2752
if (!swiftParamTyOpt) {
2733
2753
addImportDiagnostic (param,
2734
2754
Diagnostic (diag::parameter_type_not_imported, param),
@@ -3285,7 +3305,8 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
3285
3305
ImportDiagnosticAdder paramAddDiag (*this , clangDecl, param->getLocation ());
3286
3306
3287
3307
auto swiftParamTyOpt = importParameterType (
3288
- param, optionalityOfParam, allowNSUIntegerAsIntInParam,
3308
+ origDC, clangDecl, param, optionalityOfParam,
3309
+ allowNSUIntegerAsIntInParam,
3289
3310
kind == SpecialMethodKind::NSDictionarySubscriptGetter, paramIsError,
3290
3311
paramIsCompletionHandler, completionHandlerErrorParamIndex,
3291
3312
ArrayRef<GenericTypeParamDecl *>(), paramAddDiag);
0 commit comments