@@ -2323,17 +2323,20 @@ static Type validateParameterType(ParamDecl *decl) {
23232323 break ;
23242324 }
23252325
2326+ // If the element is a variadic parameter, resolve the parameter type as if
2327+ // it were in non-parameter position, since we want functions to be
2328+ // @escaping in this case.
2329+ options.setContext (isa<VarargTypeRepr>(nestedRepr)
2330+ ? TypeResolverContext::VariadicFunctionInput
2331+ : TypeResolverContext::FunctionInput);
2332+ options |= TypeResolutionFlags::Direct;
2333+
2334+ const auto resolution =
2335+ TypeResolution::forInterface (dc, options, unboundTyOpener,
2336+ PlaceholderType::get,
2337+ /* packElementOpener*/ nullptr );
2338+
23262339 if (auto *varargTypeRepr = dyn_cast<VarargTypeRepr>(nestedRepr)) {
2327- // If the element is a variadic parameter, resolve the parameter type as if
2328- // it were in non-parameter position, since we want functions to be
2329- // @escaping in this case.
2330- options.setContext (TypeResolverContext::VariadicFunctionInput);
2331- options |= TypeResolutionFlags::Direct;
2332-
2333- const auto resolution =
2334- TypeResolution::forInterface (dc, options, unboundTyOpener,
2335- PlaceholderType::get,
2336- /* packElementOpener*/ nullptr );
23372340 Ty = resolution.resolveType (nestedRepr);
23382341
23392342 // Monovariadic types (T...) for <T> resolve to [T].
@@ -2347,13 +2350,6 @@ static Type validateParameterType(ParamDecl *decl) {
23472350 return ErrorType::get (ctx);
23482351 }
23492352 } else {
2350- options.setContext (TypeResolverContext::FunctionInput);
2351- options |= TypeResolutionFlags::Direct;
2352-
2353- const auto resolution =
2354- TypeResolution::forInterface (dc, options, unboundTyOpener,
2355- PlaceholderType::get,
2356- /* packElementOpener*/ nullptr );
23572353 Ty = resolution.resolveType (decl->getTypeRepr ());
23582354 }
23592355
@@ -2364,8 +2360,7 @@ static Type validateParameterType(ParamDecl *decl) {
23642360
23652361 // Validate the presence of ownership for a parameter with an inverse applied.
23662362 if (!Ty->hasUnboundGenericType () &&
2367- diagnoseMissingOwnership (ctx, dc, ownership,
2368- decl->getTypeRepr (), Ty, options)) {
2363+ diagnoseMissingOwnership (ownership, decl->getTypeRepr (), Ty, resolution)) {
23692364 decl->setInvalid ();
23702365 return ErrorType::get (ctx);
23712366 }
0 commit comments