@@ -231,7 +231,9 @@ Solution::resolveConcreteDeclRef(ValueDecl *decl,
231
231
if (!newFn)
232
232
return ConcreteDeclRef (decl);
233
233
234
- auto newDecl = cast_or_null<ValueDecl>(decl->getASTContext ().getClangModuleLoader ()->importDeclDirectly (newFn));
234
+ auto newDecl = cast_or_null<ValueDecl>(
235
+ decl->getASTContext ().getClangModuleLoader ()->importDeclDirectly (
236
+ newFn));
235
237
236
238
if (auto fn = dyn_cast<FuncDecl>(decl)) {
237
239
if (newFn->getNumParams () != fn->getParameters ()->size ()) {
@@ -263,20 +265,26 @@ Solution::resolveConcreteDeclRef(ValueDecl *decl,
263
265
!triple.isWindowsCygwinEnvironment () &&
264
266
// Make sure we're substituting in at least one Int or UInt
265
267
// (technically not necessary).
266
- llvm::any_of (subst.getReplacementTypes (),[](Type t) {
268
+ llvm::any_of (subst.getReplacementTypes (), [](Type t) {
267
269
return t->isEqual (t->getASTContext ().getIntType ()) ||
268
270
t->isEqual (t->getASTContext ().getUIntType ());
269
271
})) {
270
- auto originalFnSubst = cast<AbstractFunctionDecl>(decl)->getInterfaceType ()->getAs <GenericFunctionType>()->substGenericArgs (subst);
271
- assert (fn->getParameters ()->size () == originalFnSubst->getParams ().size ());
272
+ auto originalFnSubst = cast<AbstractFunctionDecl>(decl)
273
+ ->getInterfaceType ()
274
+ ->getAs <GenericFunctionType>()
275
+ ->substGenericArgs (subst);
276
+ assert (fn->getParameters ()->size () ==
277
+ originalFnSubst->getParams ().size ());
272
278
SmallVector<ParamDecl *, 4 > fixedParameters;
273
279
unsigned parameterIndex = 0 ;
274
280
for (auto *newFnParam : *fn->getParameters ()) {
275
281
// If the user substituted this param with an (U)Int, use (U)Int.
276
- auto substParamType = originalFnSubst->getParams ()[parameterIndex].getParameterType ();
282
+ auto substParamType =
283
+ originalFnSubst->getParams ()[parameterIndex].getParameterType ();
277
284
if (substParamType->isEqual (fn->getASTContext ().getIntType ()) ||
278
285
substParamType->isEqual (fn->getASTContext ().getUIntType ())) {
279
- auto intParam = ParamDecl::cloneWithoutType (fn->getASTContext (), newFnParam);
286
+ auto intParam =
287
+ ParamDecl::cloneWithoutType (fn->getASTContext (), newFnParam);
280
288
intParam->setInterfaceType (substParamType);
281
289
fixedParameters.push_back (intParam);
282
290
} else {
@@ -287,17 +295,21 @@ Solution::resolveConcreteDeclRef(ValueDecl *decl,
287
295
288
296
assert (fn->getParameters ()->size () == fixedParameters.size ());
289
297
290
- auto fixedParams = ParameterList::create (fn->getASTContext (), fixedParameters);
298
+ auto fixedParams =
299
+ ParameterList::create (fn->getASTContext (), fixedParameters);
291
300
fn->setParameters (fixedParams);
292
301
293
302
// Now fix the result type:
294
- if (originalFnSubst->getResult ()->isEqual (fn->getASTContext ().getIntType ()) ||
295
- originalFnSubst->getResult ()->isEqual (fn->getASTContext ().getUIntType ())) {
303
+ if (originalFnSubst->getResult ()->isEqual (
304
+ fn->getASTContext ().getIntType ()) ||
305
+ originalFnSubst->getResult ()->isEqual (
306
+ fn->getASTContext ().getUIntType ())) {
296
307
// Constructors don't have a result.
297
308
if (auto func = dyn_cast<FuncDecl>(fn)) {
298
309
newDecl = FuncDecl::createImplicit (
299
- func->getASTContext (), func->getStaticSpelling (), func->getName (),
300
- func->getNameLoc (), func->hasAsync (), func->hasThrows (),
310
+ func->getASTContext (), func->getStaticSpelling (),
311
+ func->getName (), func->getNameLoc (), func->hasAsync (),
312
+ func->hasThrows (),
301
313
/* genericParams=*/ nullptr , fixedParams,
302
314
originalFnSubst->getResult (), func->getDeclContext ());
303
315
}
0 commit comments