@@ -2458,6 +2458,13 @@ ClangImporter::Implementation::importParameterType(
24582458 auto paramTy = desugarIfElaborated (param->getType ());
24592459 paramTy = desugarIfBoundsAttributed (paramTy);
24602460
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+
24612468 ImportTypeKind importKind = paramIsCompletionHandler
24622469 ? ImportTypeKind::CompletionHandlerParameter
24632470 : ImportTypeKind::Parameter;
@@ -2486,6 +2493,17 @@ ClangImporter::Implementation::importParameterType(
24862493 pointerKind));
24872494 return std::nullopt ;
24882495 }
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+ }
24892507 } else if (isa<clang::ReferenceType>(paramTy) &&
24902508 isa<clang::TemplateTypeParmType>(paramTy->getPointeeType ())) {
24912509 // We don't support universal reference, bail.
@@ -2734,8 +2752,6 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
27342752 }
27352753
27362754 bool knownNonNull = !nonNullArgs.empty () && nonNullArgs[index];
2737- // Specialized templates need to match the args/result exactly.
2738- knownNonNull |= clangDecl->isFunctionTemplateSpecialization ();
27392755
27402756 // Check nullability of the parameter.
27412757 OptionalTypeKind optionalityOfParam =
0 commit comments