@@ -1711,7 +1711,8 @@ static Type applyToFunctionType(
1711
1711
}
1712
1712
1713
1713
Type ClangImporter::Implementation::applyParamAttributes (
1714
- const clang::ParmVarDecl *param, Type type) {
1714
+ const clang::ParmVarDecl *param, Type type, bool &isUnsafeSendable,
1715
+ bool &isUnsafeMainActor) {
1715
1716
if (!param->hasAttrs ())
1716
1717
return type;
1717
1718
@@ -1731,7 +1732,7 @@ Type ClangImporter::Implementation::applyParamAttributes(
1731
1732
1732
1733
// Map the main-actor attribute.
1733
1734
if (isMainActorAttr (SwiftContext, swiftAttr)) {
1734
- if (Type mainActor = getMainActorType ()) {
1735
+ if (Type mainActor = SwiftContext. getMainActorType ()) {
1735
1736
type = applyToFunctionType (type, [&](ASTExtInfo extInfo) {
1736
1737
return extInfo.withGlobalActor (mainActor);
1737
1738
});
@@ -1748,6 +1749,18 @@ Type ClangImporter::Implementation::applyParamAttributes(
1748
1749
1749
1750
continue ;
1750
1751
}
1752
+
1753
+ // Map @_unsafeSendable.
1754
+ if (swiftAttr->getAttribute () == " @_unsafeSendable" ) {
1755
+ isUnsafeSendable = true ;
1756
+ continue ;
1757
+ }
1758
+
1759
+ // Map @_unsafeMainActor.
1760
+ if (swiftAttr->getAttribute () == " @_unsafeMainActor" ) {
1761
+ isUnsafeMainActor = true ;
1762
+ continue ;
1763
+ }
1751
1764
}
1752
1765
1753
1766
return type;
@@ -1928,7 +1941,10 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
1928
1941
}
1929
1942
1930
1943
// Apply attributes to the type.
1931
- swiftParamTy = applyParamAttributes (param, swiftParamTy);
1944
+ bool isUnsafeSendable = false ;
1945
+ bool isUnsafeMainActor = false ;
1946
+ swiftParamTy = applyParamAttributes (
1947
+ param, swiftParamTy, isUnsafeSendable, isUnsafeMainActor);
1932
1948
1933
1949
// Figure out the name for this parameter.
1934
1950
Identifier bodyName = importFullName (param, CurrentVersion)
@@ -1949,6 +1965,8 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
1949
1965
paramInfo->setSpecifier (ParamSpecifier::Default);
1950
1966
paramInfo->setInterfaceType (swiftParamTy);
1951
1967
recordImplicitUnwrapForDecl (paramInfo, isParamTypeImplicitlyUnwrapped);
1968
+ recordUnsafeConcurrencyForDecl (
1969
+ paramInfo, isUnsafeSendable, isUnsafeMainActor);
1952
1970
parameters.push_back (paramInfo);
1953
1971
++index;
1954
1972
}
@@ -2426,7 +2444,10 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
2426
2444
}
2427
2445
2428
2446
// Apply Clang attributes to the parameter type.
2429
- swiftParamTy = applyParamAttributes (param, swiftParamTy);
2447
+ bool isUnsafeSendable = false ;
2448
+ bool isUnsafeMainActor = false ;
2449
+ swiftParamTy = applyParamAttributes (
2450
+ param, swiftParamTy, isUnsafeSendable, isUnsafeMainActor);
2430
2451
2431
2452
// Figure out the name for this parameter.
2432
2453
Identifier bodyName = importFullName (param, CurrentVersion)
@@ -2450,6 +2471,8 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
2450
2471
paramInfo->setSpecifier (ParamSpecifier::Default);
2451
2472
paramInfo->setInterfaceType (swiftParamTy);
2452
2473
recordImplicitUnwrapForDecl (paramInfo, paramIsIUO);
2474
+ recordUnsafeConcurrencyForDecl (
2475
+ paramInfo, isUnsafeSendable, isUnsafeMainActor);
2453
2476
2454
2477
// Determine whether we have a default argument.
2455
2478
if (kind == SpecialMethodKind::Regular ||
0 commit comments