@@ -2458,6 +2458,13 @@ ClangImporter::Implementation::importParameterType(
2458
2458
auto paramTy = desugarIfElaborated (param->getType ());
2459
2459
paramTy = desugarIfBoundsAttributed (paramTy);
2460
2460
2461
+ // If this type has a _Nullable/_Nonnull attribute, drop it, since we already
2462
+ // have that information in optionalityOfParam.
2463
+ if (auto attributedTy = dyn_cast<clang::AttributedType>(paramTy)) {
2464
+ if (attributedTy->getImmediateNullability ())
2465
+ clang::AttributedType::stripOuterNullability (paramTy);
2466
+ }
2467
+
2461
2468
ImportTypeKind importKind = paramIsCompletionHandler
2462
2469
? ImportTypeKind::CompletionHandlerParameter
2463
2470
: ImportTypeKind::Parameter;
@@ -2486,6 +2493,17 @@ ClangImporter::Implementation::importParameterType(
2486
2493
pointerKind));
2487
2494
return std::nullopt ;
2488
2495
}
2496
+ switch (optionalityOfParam) {
2497
+ case OTK_Optional:
2498
+ swiftParamTy = OptionalType::get (swiftParamTy);
2499
+ break ;
2500
+ case OTK_ImplicitlyUnwrappedOptional:
2501
+ swiftParamTy = OptionalType::get (swiftParamTy);
2502
+ isParamTypeImplicitlyUnwrapped = true ;
2503
+ break ;
2504
+ case OTK_None:
2505
+ break ;
2506
+ }
2489
2507
} else if (isa<clang::ReferenceType>(paramTy) &&
2490
2508
isa<clang::TemplateTypeParmType>(paramTy->getPointeeType ())) {
2491
2509
// We don't support universal reference, bail.
@@ -2734,8 +2752,6 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
2734
2752
}
2735
2753
2736
2754
bool knownNonNull = !nonNullArgs.empty () && nonNullArgs[index];
2737
- // Specialized templates need to match the args/result exactly.
2738
- knownNonNull |= clangDecl->isFunctionTemplateSpecialization ();
2739
2755
2740
2756
// Check nullability of the parameter.
2741
2757
OptionalTypeKind optionalityOfParam =
0 commit comments