@@ -2241,21 +2241,23 @@ getImportTypeKindForParam(const clang::ParmVarDecl *param) {
2241
2241
return importKind;
2242
2242
}
2243
2243
2244
- Optional<swift::Type> ClangImporter::Implementation::importParameterType (
2244
+ Optional<ClangImporter::Implementation::ImportParameterTypeResult>
2245
+ ClangImporter::Implementation::importParameterType (
2245
2246
const clang::ParmVarDecl *param, OptionalTypeKind optionalityOfParam,
2246
2247
bool allowNSUIntegerAsInt, bool isNSDictionarySubscriptGetter,
2247
2248
bool paramIsError, bool paramIsCompletionHandler,
2248
2249
Optional<unsigned > completionHandlerErrorParamIndex,
2249
2250
ArrayRef<GenericTypeParamDecl *> genericParams,
2250
- llvm::function_ref<void (Diagnostic &&)> addImportDiagnosticFn,
2251
- bool &isInOut, bool &isParamTypeImplicitlyUnwrapped) {
2251
+ llvm::function_ref<void (Diagnostic &&)> addImportDiagnosticFn) {
2252
2252
auto paramTy = param->getType ();
2253
2253
2254
2254
ImportTypeKind importKind = getImportTypeKindForParam (param);
2255
2255
2256
2256
// Import the parameter type into Swift.
2257
2257
auto attrs = getImportTypeAttrs (param, /* isParam=*/ true );
2258
2258
Type swiftParamTy;
2259
+ bool isInOut = false ;
2260
+ bool isParamTypeImplicitlyUnwrapped = false ;
2259
2261
2260
2262
// Sometimes we import unavailable typedefs as enums. If that's the case,
2261
2263
// use the enum, not the typedef here.
@@ -2351,7 +2353,8 @@ Optional<swift::Type> ClangImporter::Implementation::importParameterType(
2351
2353
swiftParamTy = importedType.getType ();
2352
2354
}
2353
2355
2354
- return swiftParamTy;
2356
+ return ImportParameterTypeResult{swiftParamTy, isInOut,
2357
+ isParamTypeImplicitlyUnwrapped};
2355
2358
}
2356
2359
2357
2360
static ParamDecl *getParameterInfo (ClangImporter::Implementation *impl,
@@ -2409,23 +2412,22 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
2409
2412
2410
2413
ImportDiagnosticAdder paramAddDiag (*this , clangDecl, param->getLocation ());
2411
2414
2412
- bool isInOut = false ;
2413
- bool isParamTypeImplicitlyUnwrapped = false ;
2414
-
2415
2415
auto swiftParamTyOpt = importParameterType (
2416
2416
param, optionalityOfParam, allowNSUIntegerAsInt,
2417
2417
/* isNSDictionarySubscriptGetter=*/ false ,
2418
2418
/* paramIsError=*/ false ,
2419
2419
/* paramIsCompletionHandler=*/ false ,
2420
- /* completionHandlerErrorParamIndex=*/ None, genericParams, paramAddDiag,
2421
- isInOut, isParamTypeImplicitlyUnwrapped);
2420
+ /* completionHandlerErrorParamIndex=*/ None, genericParams, paramAddDiag);
2422
2421
if (!swiftParamTyOpt) {
2423
2422
addImportDiagnostic (param,
2424
2423
Diagnostic (diag::parameter_type_not_imported, param),
2425
2424
param->getSourceRange ().getBegin ());
2426
2425
return nullptr ;
2427
2426
}
2428
- auto swiftParamTy = *swiftParamTyOpt;
2427
+ auto swiftParamTy = swiftParamTyOpt->swiftTy ;
2428
+ bool isInOut = swiftParamTyOpt->isInOut ;
2429
+ bool isParamTypeImplicitlyUnwrapped =
2430
+ swiftParamTyOpt->isParamTypeImplicitlyUnwrapped ;
2429
2431
2430
2432
// Retrieve the argument name.
2431
2433
Identifier name;
@@ -2984,20 +2986,21 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
2984
2986
2985
2987
ImportDiagnosticAdder paramAddDiag (*this , clangDecl, param->getLocation ());
2986
2988
2987
- bool isInOut = false ;
2988
- bool paramIsIUO = false ;
2989
2989
auto swiftParamTyOpt = importParameterType (
2990
2990
param, optionalityOfParam, allowNSUIntegerAsIntInParam,
2991
2991
kind == SpecialMethodKind::NSDictionarySubscriptGetter, paramIsError,
2992
2992
paramIsCompletionHandler, completionHandlerErrorParamIndex,
2993
- ArrayRef<GenericTypeParamDecl *>(), paramAddDiag, isInOut, paramIsIUO );
2993
+ ArrayRef<GenericTypeParamDecl *>(), paramAddDiag);
2994
2994
if (!swiftParamTyOpt) {
2995
2995
addImportDiagnostic (param,
2996
2996
Diagnostic (diag::parameter_type_not_imported, param),
2997
2997
param->getSourceRange ().getBegin ());
2998
2998
return {Type (), false };
2999
2999
}
3000
- auto swiftParamTy = *swiftParamTyOpt;
3000
+ auto swiftParamTy = swiftParamTyOpt->swiftTy ;
3001
+ bool isInOut = swiftParamTyOpt->isInOut ;
3002
+ bool isParamTypeImplicitlyUnwrapped =
3003
+ swiftParamTyOpt->isParamTypeImplicitlyUnwrapped ;
3001
3004
3002
3005
swiftParamTy = mapGenericArgs (origDC, dc, swiftParamTy);
3003
3006
@@ -3044,8 +3047,8 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
3044
3047
++nameIndex;
3045
3048
3046
3049
// Set up the parameter info
3047
- auto paramInfo =
3048
- getParameterInfo ( this , param, name, swiftParamTy, isInOut, paramIsIUO );
3050
+ auto paramInfo = getParameterInfo ( this , param, name, swiftParamTy, isInOut,
3051
+ isParamTypeImplicitlyUnwrapped );
3049
3052
3050
3053
// Determine whether we have a default argument.
3051
3054
if (kind == SpecialMethodKind::Regular ||
0 commit comments