@@ -2121,17 +2121,10 @@ ResultTypeRequest::evaluate(Evaluator &evaluator, ValueDecl *decl) const {
2121
2121
if (decl->preconcurrency ())
2122
2122
options |= TypeResolutionFlags::Preconcurrency;
2123
2123
2124
- // Placeholders are only currently allowed for FuncDecls with bodies, which
2125
- // we diagnose in ReturnTypePlaceholderReplacer.
2126
- HandlePlaceholderTypeReprFn placeholderOpener;
2127
- if (auto *FD = dyn_cast<FuncDecl>(decl)) {
2128
- if (FD->hasBody () && !FD->isBodySkipped ())
2129
- placeholderOpener = PlaceholderType::get;
2130
- }
2131
2124
auto *const dc = decl->getInnermostDeclContext ();
2132
2125
return TypeResolution::forInterface (dc, options,
2133
2126
/* unboundTyOpener*/ nullptr ,
2134
- placeholderOpener,
2127
+ /* placeholderOpener*/ nullptr ,
2135
2128
/* packElementOpener*/ nullptr )
2136
2129
.resolveType (resultTyRepr);
2137
2130
}
@@ -2259,6 +2252,7 @@ static Type validateParameterType(ParamDecl *decl) {
2259
2252
2260
2253
TypeResolutionOptions options (std::nullopt );
2261
2254
OpenUnboundGenericTypeFn unboundTyOpener = nullptr ;
2255
+ HandlePlaceholderTypeReprFn placeholderOpener = nullptr ;
2262
2256
if (isa<AbstractClosureExpr>(dc)) {
2263
2257
options = TypeResolutionOptions (TypeResolverContext::ClosureExpr);
2264
2258
options |= TypeResolutionFlags::AllowUnspecifiedTypes;
@@ -2267,8 +2261,9 @@ static Type validateParameterType(ParamDecl *decl) {
2267
2261
// For now, just return the unbound generic type.
2268
2262
return unboundTy;
2269
2263
};
2270
- // FIXME: Don't let placeholder types escape type resolution.
2271
- // For now, just return the placeholder type.
2264
+ // FIXME: Don't let placeholder types escape type resolution. For now, just
2265
+ // return the placeholder type, which we open in `inferClosureType`.
2266
+ placeholderOpener = PlaceholderType::get;
2272
2267
} else if (isa<AbstractFunctionDecl>(dc)) {
2273
2268
options = TypeResolutionOptions (TypeResolverContext::AbstractFunctionDecl);
2274
2269
} else if (isa<SubscriptDecl>(dc)) {
@@ -2317,14 +2312,6 @@ static Type validateParameterType(ParamDecl *decl) {
2317
2312
: TypeResolverContext::FunctionInput);
2318
2313
options |= TypeResolutionFlags::Direct;
2319
2314
2320
- // We allow placeholders in parameter types to improve recovery since if a
2321
- // default argument is present we can suggest the inferred type. Avoid doing
2322
- // this for protocol requirements though since those can't ever have default
2323
- // arguments anyway.
2324
- HandlePlaceholderTypeReprFn placeholderOpener;
2325
- if (!isa<ProtocolDecl>(dc->getParent ()))
2326
- placeholderOpener = PlaceholderType::get;
2327
-
2328
2315
const auto resolution =
2329
2316
TypeResolution::forInterface (dc, options, unboundTyOpener,
2330
2317
placeholderOpener,
0 commit comments