@@ -2295,12 +2295,14 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
2295
2295
2296
2296
ImportTypeKind importKind = getImportTypeKindForParam (param);
2297
2297
2298
- // Import the parameter type into Swift.
2299
2298
ImportDiagnosticAdder paramAddDiag (*this , clangDecl, param->getLocation ());
2299
+
2300
+ bool isInOut = false ;
2301
+ bool isParamTypeImplicitlyUnwrapped = false ;
2302
+
2303
+ // Import the parameter type into Swift.
2300
2304
auto attrs = getImportTypeAttrs (param, /* isParam=*/ true );
2301
2305
Type swiftParamTy;
2302
- bool isParamTypeImplicitlyUnwrapped = false ;
2303
- bool isInOut = false ;
2304
2306
2305
2307
// Sometimes we import unavailable typedefs as enums. If that's the case,
2306
2308
// use the enum, not the typedef here.
@@ -2902,13 +2904,20 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
2902
2904
2903
2905
bool paramIsCompletionHandler =
2904
2906
asyncInfo && paramIndex == asyncInfo->completionHandlerParamIndex ();
2905
-
2906
- // Import the parameter type into Swift.
2907
+ // Figure out if this is a completion handler parameter whose error
2908
+ // parameter is used to indicate throwing.
2909
+ Optional<unsigned > completionHandlerErrorParamIndex;
2910
+ if (isAsync && paramIsCompletionHandler) {
2911
+ completionHandlerErrorParamIndex =
2912
+ asyncInfo->completionHandlerErrorParamIndex ();
2913
+ }
2907
2914
2908
2915
// Check nullability of the parameter.
2909
- OptionalTypeKind optionalityOfParam
2910
- = getParamOptionality (param,
2911
- !nonNullArgs.empty () && nonNullArgs[paramIndex]);
2916
+ bool knownNonNull = !nonNullArgs.empty () && nonNullArgs[paramIndex];
2917
+ OptionalTypeKind optionalityOfParam =
2918
+ getParamOptionality (param, knownNonNull);
2919
+
2920
+ // Import the parameter type into Swift.
2912
2921
2913
2922
bool allowNSUIntegerAsIntInParam = isFromSystemModule;
2914
2923
if (allowNSUIntegerAsIntInParam) {
@@ -2922,11 +2931,13 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
2922
2931
allowNSUIntegerAsIntInParam = !nameContainsUnsigned (name);
2923
2932
}
2924
2933
2925
- // Special case for NSDictionary's subscript.
2926
2934
ImportTypeKind importKind = getImportTypeKindForParam (param);
2927
2935
ImportDiagnosticAdder paramAddDiag (*this , clangDecl, param->getLocation ());
2928
- Type swiftParamTy;
2936
+
2937
+ bool isInOut = false ;
2929
2938
bool paramIsIUO = false ;
2939
+
2940
+ Type swiftParamTy;
2930
2941
if (auto typedefType = dyn_cast<clang::TypedefType>(paramTy.getTypePtr ())) {
2931
2942
if (isUnavailableInSwift (typedefType->getDecl ())) {
2932
2943
if (auto clangEnum = findAnonymousEnumForTypedef (SwiftContext, typedefType)) {
@@ -2941,6 +2952,7 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
2941
2952
}
2942
2953
}
2943
2954
2955
+ // Special case for NSDictionary's subscript.
2944
2956
if (kind == SpecialMethodKind::NSDictionarySubscriptGetter &&
2945
2957
paramTy->isObjCIdType ()) {
2946
2958
// Not using `getImportTypeAttrs()` is unprincipled but OK for this hack.
@@ -2953,14 +2965,6 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
2953
2965
2954
2966
paramIsIUO = optionalityOfParam == OTK_ImplicitlyUnwrappedOptional;
2955
2967
} else if (!swiftParamTy) {
2956
- // Figure out if this is a completion handler parameter whose error
2957
- // parameter is used to indicate throwing.
2958
- Optional<unsigned > completionHandlerErrorParamIndex;
2959
- if (isAsync && paramIsCompletionHandler) {
2960
- completionHandlerErrorParamIndex =
2961
- asyncInfo->completionHandlerErrorParamIndex ();
2962
- }
2963
-
2964
2968
bool sendableByDefault = paramIsCompletionHandler &&
2965
2969
SwiftContext.LangOpts .hasFeature (Feature::SendableCompletionHandlers);
2966
2970
@@ -3033,8 +3037,8 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
3033
3037
++nameIndex;
3034
3038
3035
3039
// Set up the parameter info
3036
- auto paramInfo = getParameterInfo ( this , param, name, swiftParamTy,
3037
- /* isInOut= */ false , paramIsIUO);
3040
+ auto paramInfo =
3041
+ getParameterInfo ( this , param, name, swiftParamTy, isInOut, paramIsIUO);
3038
3042
3039
3043
// Determine whether we have a default argument.
3040
3044
if (kind == SpecialMethodKind::Regular ||
0 commit comments