@@ -391,18 +391,10 @@ class Callee {
391
391
392
392
void setSubstitutions (SILGenFunction &gen,
393
393
SILLocation loc,
394
- ArrayRef<Substitution> newSubs,
395
- unsigned callDepth) {
396
- // Currently generic methods of generic types are the deepest we should
397
- // be able to stack specializations.
398
- // FIXME: Generic local functions can add type parameters to arbitrary
399
- // depth.
400
- assert (callDepth < 2 && " specialization below 'self' or argument depth?!" );
394
+ ArrayRef<Substitution> newSubs) {
401
395
assert (Substitutions.empty () && " Already have substitutions?" );
402
396
Substitutions = newSubs;
403
397
404
- assert (getNaturalUncurryLevel () >= callDepth
405
- && " specializations below uncurry level?!" );
406
398
SpecializeLoc = loc;
407
399
HasSubstitutions = true ;
408
400
}
@@ -808,13 +800,6 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
808
800
std::vector<ApplyExpr*> CallSites;
809
801
Expr *SideEffect = nullptr ;
810
802
811
- // / The depth of uncurries that we have seen.
812
- // /
813
- // / *NOTE* This counter is incremented *after* we return from visiting a call
814
- // / site's children. This means that it is not valid until we finish visiting
815
- // / the expression.
816
- unsigned CallDepth = 0 ;
817
-
818
803
// / When visiting expressions, sometimes we need to emit self before we know
819
804
// / what the actual callee is. In such cases, we assume that we are passing
820
805
// / self at +0 and then after we know what the callee is, we check if the
@@ -826,8 +811,6 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
826
811
{}
827
812
828
813
void setCallee (Callee &&c) {
829
- assert ((SelfParam ? CallDepth == 1 : CallDepth == 0 )
830
- && " setting callee at non-zero call depth?!" );
831
814
assert (!ApplyCallee && " already set callee!" );
832
815
ApplyCallee.emplace (std::move (c));
833
816
}
@@ -842,14 +825,12 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
842
825
SelfParam = std::move (theSelfParam);
843
826
SelfApplyExpr = theSelfApplyExpr;
844
827
SelfType = theSelfApplyExpr->getType ();
845
- ++CallDepth;
846
828
}
847
829
void setSelfParam (ArgumentSource &&theSelfParam, Type selfType) {
848
830
assert (!SelfParam && " already set this!" );
849
831
SelfParam = std::move (theSelfParam);
850
832
SelfApplyExpr = nullptr ;
851
833
SelfType = selfType;
852
- ++CallDepth;
853
834
}
854
835
855
836
void decompose (Expr *e) {
@@ -933,7 +914,6 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
933
914
CallSites.push_back (e);
934
915
visit (e->getFn ());
935
916
}
936
- ++CallDepth;
937
917
}
938
918
939
919
// / Given a metatype value for the type, allocate an Objective-C
@@ -1041,9 +1021,8 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
1041
1021
setCallee (std::move (theCallee));
1042
1022
1043
1023
// If there are substitutions, add them now.
1044
- if (!subs.empty ()) {
1045
- ApplyCallee->setSubstitutions (SGF, e, subs, CallDepth);
1046
- }
1024
+ if (!subs.empty ())
1025
+ ApplyCallee->setSubstitutions (SGF, e, subs);
1047
1026
1048
1027
return ;
1049
1028
}
@@ -1125,15 +1104,10 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
1125
1104
setCallee (Callee::forClassMethod (SGF, selfValue,
1126
1105
constant, getSubstFnType (), e));
1127
1106
1128
- // setSelfParam bumps the callDepth, but we aren't really past the
1129
- // 'self' call depth in this case.
1130
- --CallDepth;
1131
-
1132
1107
// If there are substitutions, add them.
1133
1108
if (e->getDeclRef ().isSpecialized ()) {
1134
1109
ApplyCallee->setSubstitutions (SGF, e,
1135
- e->getDeclRef ().getSubstitutions (),
1136
- CallDepth);
1110
+ e->getDeclRef ().getSubstitutions ());
1137
1111
}
1138
1112
1139
1113
return ;
@@ -1192,12 +1166,12 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
1192
1166
}
1193
1167
}
1194
1168
1195
- // If there are substitutions, add them, always at depth 0 .
1169
+ // If there are substitutions, add them.
1196
1170
if (!subs.empty () &&
1197
1171
(!afd ||
1198
1172
!afd->getDeclContext ()->isLocalContext () ||
1199
1173
afd->getCaptureInfo ().hasGenericParamCaptures ()))
1200
- ApplyCallee->setSubstitutions (SGF, e, subs, 0 );
1174
+ ApplyCallee->setSubstitutions (SGF, e, subs);
1201
1175
}
1202
1176
1203
1177
void visitAbstractClosureExpr (AbstractClosureExpr *e) {
@@ -1242,9 +1216,9 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
1242
1216
captures);
1243
1217
ApplyCallee->setCaptures (std::move (captures));
1244
1218
}
1245
- // If there are substitutions, add them, always at depth 0 .
1219
+ // If there are substitutions, add them.
1246
1220
if (!subs.empty ())
1247
- ApplyCallee->setSubstitutions (SGF, e, subs, 0 );
1221
+ ApplyCallee->setSubstitutions (SGF, e, subs);
1248
1222
}
1249
1223
1250
1224
void visitOtherConstructorDeclRefExpr (OtherConstructorDeclRefExpr *e) {
@@ -1257,8 +1231,7 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
1257
1231
1258
1232
// If there are substitutions, add them.
1259
1233
if (e->getDeclRef ().isSpecialized ())
1260
- ApplyCallee->setSubstitutions (SGF, e, e->getDeclRef ().getSubstitutions (),
1261
- CallDepth);
1234
+ ApplyCallee->setSubstitutions (SGF, e, e->getDeclRef ().getSubstitutions ());
1262
1235
}
1263
1236
void visitDotSyntaxBaseIgnoredExpr (DotSyntaxBaseIgnoredExpr *e) {
1264
1237
setSideEffect (e->getLHS ());
@@ -1326,7 +1299,7 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
1326
1299
1327
1300
// If there are any substitutions for the callee, apply them now.
1328
1301
if (!substitutions.empty ())
1329
- ApplyCallee->setSubstitutions (SGF, fn, substitutions, CallDepth- 1 );
1302
+ ApplyCallee->setSubstitutions (SGF, fn, substitutions);
1330
1303
}
1331
1304
1332
1305
// / Walk the given \c selfArg expression that produces the appropriate
@@ -1518,8 +1491,7 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
1518
1491
// Set up the substitutions, if we have any.
1519
1492
if (ctorRef->getDeclRef ().isSpecialized ())
1520
1493
ApplyCallee->setSubstitutions (SGF, fn,
1521
- ctorRef->getDeclRef ().getSubstitutions (),
1522
- CallDepth-1 );
1494
+ ctorRef->getDeclRef ().getSubstitutions ());
1523
1495
1524
1496
return true ;
1525
1497
}
@@ -4266,7 +4238,7 @@ SILGenFunction::emitApplyOfLibraryIntrinsic(SILLocation loc,
4266
4238
}
4267
4239
4268
4240
auto callee = Callee::forDirect (*this , SILDeclRef (fn), substFormalType, loc);
4269
- callee.setSubstitutions (*this , loc, subs, 0 );
4241
+ callee.setSubstitutions (*this , loc, subs);
4270
4242
4271
4243
ManagedValue mv;
4272
4244
CanSILFunctionType substFnType;
@@ -4438,7 +4410,7 @@ emitSpecializedAccessorFunctionRef(SILGenFunction &gen,
4438
4410
// FIXME: Generic subscript operator could add another layer of
4439
4411
// substitutions.
4440
4412
if (!substitutions.empty ()) {
4441
- callee.setSubstitutions (gen, loc, substitutions, 0 );
4413
+ callee.setSubstitutions (gen, loc, substitutions);
4442
4414
}
4443
4415
return callee;
4444
4416
}
0 commit comments