@@ -207,39 +207,35 @@ class AbstractFunction {
207
207
unsigned TheKind : 2 ;
208
208
unsigned ParamCount : 2 ;
209
209
FunctionRethrowingKind RethrowingKind;
210
- ConcreteDeclRef declRef ;
210
+ SubstitutionMap Substitutions ;
211
211
212
212
public:
213
- explicit AbstractFunction (Kind kind, Expr *fn, ConcreteDeclRef declRef )
213
+ explicit AbstractFunction (Kind kind, Expr *fn)
214
214
: TheKind(kind),
215
215
ParamCount(1 ),
216
- RethrowingKind(FunctionRethrowingKind::None),
217
- declRef(declRef) {
216
+ RethrowingKind(FunctionRethrowingKind::None) {
218
217
TheExpr = fn;
219
218
}
220
219
221
- explicit AbstractFunction (AbstractFunctionDecl *fn, ConcreteDeclRef declRef )
220
+ explicit AbstractFunction (AbstractFunctionDecl *fn, SubstitutionMap subs )
222
221
: TheKind(Kind::Function),
223
222
ParamCount(fn->getNumCurryLevels ()),
224
223
RethrowingKind(fn->getRethrowingKind ()),
225
- declRef(declRef ) {
224
+ Substitutions(subs ) {
226
225
TheFunction = fn;
227
226
}
228
227
229
- explicit AbstractFunction (AbstractClosureExpr *closure,
230
- ConcreteDeclRef declRef)
228
+ explicit AbstractFunction (AbstractClosureExpr *closure)
231
229
: TheKind(Kind::Closure),
232
230
ParamCount(1 ),
233
- RethrowingKind(FunctionRethrowingKind::None),
234
- declRef(declRef) {
231
+ RethrowingKind(FunctionRethrowingKind::None) {
235
232
TheClosure = closure;
236
233
}
237
234
238
- explicit AbstractFunction (ParamDecl *parameter, ConcreteDeclRef declRef )
235
+ explicit AbstractFunction (ParamDecl *parameter)
239
236
: TheKind(Kind::Parameter),
240
237
ParamCount(1 ),
241
- RethrowingKind(FunctionRethrowingKind::None),
242
- declRef(declRef) {
238
+ RethrowingKind(FunctionRethrowingKind::None) {
243
239
TheParameter = parameter;
244
240
}
245
241
@@ -300,29 +296,22 @@ class AbstractFunction {
300
296
return TheExpr;
301
297
}
302
298
303
- ConcreteDeclRef getDeclRef () {
304
- return declRef ;
299
+ SubstitutionMap getSubstitutions () const {
300
+ return Substitutions ;
305
301
}
306
302
307
303
static AbstractFunction decomposeApply (ApplyExpr *apply,
308
304
SmallVectorImpl<Expr*> &args) {
309
305
Expr *fn;
310
- ConcreteDeclRef declRef;
311
306
do {
312
307
args.push_back (apply->getArg ());
313
- auto applyFn = apply->getFn ();
314
- if (!declRef) {
315
- if (auto DRE = dyn_cast<DeclRefExpr>(applyFn)) {
316
- declRef = DRE->getDeclRef ();
317
- }
318
- }
319
- fn = applyFn->getValueProvidingExpr ();
308
+ fn = apply->getFn ()->getValueProvidingExpr ();
320
309
} while ((apply = dyn_cast<ApplyExpr>(fn)));
321
310
322
- return decomposeFunction (fn, declRef );
311
+ return decomposeFunction (fn);
323
312
}
324
313
325
- static AbstractFunction decomposeFunction (Expr *fn, ConcreteDeclRef declRef = ConcreteDeclRef() ) {
314
+ static AbstractFunction decomposeFunction (Expr *fn) {
326
315
assert (fn->getValueProvidingExpr () == fn);
327
316
328
317
while (true ) {
@@ -353,25 +342,26 @@ class AbstractFunction {
353
342
354
343
// Constructor delegation.
355
344
if (auto otherCtorDeclRef = dyn_cast<OtherConstructorDeclRefExpr>(fn)) {
356
- return AbstractFunction (otherCtorDeclRef->getDecl (), declRef);
345
+ return AbstractFunction (otherCtorDeclRef->getDecl (),
346
+ otherCtorDeclRef->getDeclRef ().getSubstitutions ());
357
347
}
358
348
359
349
// Normal function references.
360
350
if (auto DRE = dyn_cast<DeclRefExpr>(fn)) {
361
351
ValueDecl *decl = DRE->getDecl ();
362
352
if (auto fn = dyn_cast<AbstractFunctionDecl>(decl)) {
363
- return AbstractFunction (fn, declRef );
353
+ return AbstractFunction (fn, DRE-> getDeclRef (). getSubstitutions () );
364
354
} else if (auto param = dyn_cast<ParamDecl>(decl)) {
365
- return AbstractFunction (param, declRef );
355
+ return AbstractFunction (param);
366
356
}
367
357
368
358
// Closures.
369
359
} else if (auto closure = dyn_cast<AbstractClosureExpr>(fn)) {
370
- return AbstractFunction (closure, declRef );
360
+ return AbstractFunction (closure);
371
361
}
372
362
373
363
// Everything else is opaque.
374
- return AbstractFunction (Kind::Opaque, fn, declRef );
364
+ return AbstractFunction (Kind::Opaque, fn);
375
365
}
376
366
};
377
367
@@ -688,7 +678,7 @@ class ApplyClassifier {
688
678
}
689
679
690
680
if (fnRef.getRethrowingKind () == FunctionRethrowingKind::ByConformance) {
691
- auto substitutions = fnRef.getDeclRef (). getSubstitutions ();
681
+ auto substitutions = fnRef.getSubstitutions ();
692
682
bool classifiedAsThrows = false ;
693
683
for (auto conformanceRef : substitutions.getConformances ()) {
694
684
if (conformanceRef.classifyAsThrows ()) {
0 commit comments