@@ -2856,10 +2856,10 @@ static bool candidatesHaveAnyDefaultValues(
2856
2856
if (!function) continue ;
2857
2857
2858
2858
if (function->hasImplicitSelfDecl ()) {
2859
- if (cand.level != 1 )
2859
+ if (! cand.skipCurriedSelf )
2860
2860
return false ;
2861
2861
} else {
2862
- if (cand.level != 0 )
2862
+ if (cand.skipCurriedSelf )
2863
2863
return false ;
2864
2864
}
2865
2865
@@ -2910,10 +2910,10 @@ static Optional<unsigned> getElementForScalarInitOfArg(
2910
2910
if (!function) return getElementForScalarInitSimple (tupleTy);
2911
2911
2912
2912
if (function->hasImplicitSelfDecl ()) {
2913
- if (cand.level != 1 )
2913
+ if (! cand.skipCurriedSelf )
2914
2914
return getElementForScalarInitSimple (tupleTy);
2915
2915
} else {
2916
- if (cand.level != 0 )
2916
+ if (cand.skipCurriedSelf )
2917
2917
return getElementForScalarInitSimple (tupleTy);
2918
2918
}
2919
2919
@@ -2987,7 +2987,7 @@ typeCheckArgumentChildIndependently(Expr *argExpr, Type argType,
2987
2987
// diagnostics when we don't force the self type down.
2988
2988
if (argType && !candidates.empty ())
2989
2989
if (auto decl = candidates[0 ].getDecl ())
2990
- if (decl->isInstanceMember () && candidates[0 ].level == 0 &&
2990
+ if (decl->isInstanceMember () && ! candidates[0 ].skipCurriedSelf &&
2991
2991
!isa<SubscriptDecl>(decl))
2992
2992
argType = Type ();
2993
2993
@@ -3052,7 +3052,7 @@ typeCheckArgumentChildIndependently(Expr *argExpr, Type argType,
3052
3052
SmallBitVector defaultMap (params.size ());
3053
3053
if (!candidates.empty ()) {
3054
3054
defaultMap = computeDefaultMap (params, candidates[0 ].getDecl (),
3055
- candidates[0 ].level );
3055
+ candidates[0 ].skipCurriedSelf );
3056
3056
}
3057
3057
3058
3058
// Form a set of call arguments, using a dummy type (Void), because the
@@ -3461,14 +3461,15 @@ diagnoseInstanceMethodAsCurriedMemberOnType(CalleeCandidateInfo &CCI,
3461
3461
// it might be worth while to check if it's instance method as curried
3462
3462
// member of type problem.
3463
3463
if (CCI.closeness == CC_ExactMatch &&
3464
- (decl->isInstanceMember () && candidate.level == 1 ))
3464
+ (decl->isInstanceMember () && candidate.skipCurriedSelf ))
3465
3465
continue ;
3466
3466
3467
3467
auto params = candidate.getParameters ();
3468
3468
// If one of the candidates is an instance method with a single parameter
3469
3469
// at the level 0, this might be viable situation for calling instance
3470
3470
// method as curried member of type problem.
3471
- if (params.size () != 1 || !decl->isInstanceMember () || candidate.level > 0 )
3471
+ if (params.size () != 1 || !decl->isInstanceMember () ||
3472
+ candidate.skipCurriedSelf )
3472
3473
return false ;
3473
3474
}
3474
3475
@@ -4020,7 +4021,7 @@ diagnoseSingleCandidateFailures(CalleeCandidateInfo &CCI, Expr *fnExpr,
4020
4021
auto params = candidate.getParameters ();
4021
4022
4022
4023
SmallBitVector defaultMap =
4023
- computeDefaultMap (params, candidate.getDecl (), candidate.level );
4024
+ computeDefaultMap (params, candidate.getDecl (), candidate.skipCurriedSelf );
4024
4025
auto args = decomposeArgType (CCI.CS .getType (argExpr), argLabels);
4025
4026
4026
4027
// Check the case where a raw-representable type is constructed from an
@@ -4034,7 +4035,7 @@ diagnoseSingleCandidateFailures(CalleeCandidateInfo &CCI, Expr *fnExpr,
4034
4035
// MyEnumType.foo
4035
4036
//
4036
4037
if (params.size () == 1 && args.size () == 1 && candidate.getDecl () &&
4037
- isa<ConstructorDecl>(candidate.getDecl ()) && candidate.level == 1 ) {
4038
+ isa<ConstructorDecl>(candidate.getDecl ()) && candidate.skipCurriedSelf ) {
4038
4039
AnyFunctionType::Param &arg = args[0 ];
4039
4040
auto resTy =
4040
4041
candidate.getResultType ()->lookThroughAllOptionalTypes ();
@@ -4320,7 +4321,7 @@ bool FailureDiagnosis::diagnoseSubscriptErrors(SubscriptExpr *SE,
4320
4321
// We're about to typecheck the index list, which needs to be processed with
4321
4322
// self already applied.
4322
4323
for (unsigned i = 0 , e = calleeInfo.size (); i != e; ++i)
4323
- ++ calleeInfo.candidates [i].level ;
4324
+ calleeInfo.candidates [i].skipCurriedSelf = true ;
4324
4325
4325
4326
auto indexExpr =
4326
4327
typeCheckArgumentChildIndependently (SE->getIndex (), Type (), calleeInfo);
@@ -4329,7 +4330,7 @@ bool FailureDiagnosis::diagnoseSubscriptErrors(SubscriptExpr *SE,
4329
4330
4330
4331
// Back to analyzing the candidate list with self applied.
4331
4332
for (unsigned i = 0 , e = calleeInfo.size (); i != e; ++i)
4332
- -- calleeInfo.candidates [i].level ;
4333
+ calleeInfo.candidates [i].skipCurriedSelf = false ;
4333
4334
4334
4335
ArrayRef<Identifier> argLabels = SE->getArgumentLabels ();
4335
4336
if (diagnoseParameterErrors (calleeInfo, SE, indexExpr, argLabels))
@@ -4353,9 +4354,8 @@ bool FailureDiagnosis::diagnoseSubscriptErrors(SubscriptExpr *SE,
4353
4354
CC_ExactMatch)
4354
4355
selfConstraint = CC_SelfMismatch;
4355
4356
4356
- // Increase the uncurry level to look past the self argument to the
4357
- // indices.
4358
- cand.level ++;
4357
+ // Set a flag to look past the self argument to the indices.
4358
+ cand.skipCurriedSelf = true ;
4359
4359
4360
4360
// Explode out multi-index subscripts to find the best match.
4361
4361
auto indexResult =
@@ -4378,7 +4378,7 @@ bool FailureDiagnosis::diagnoseSubscriptErrors(SubscriptExpr *SE,
4378
4378
4379
4379
// Any other failures relate to the index list.
4380
4380
for (unsigned i = 0 , e = calleeInfo.size (); i != e; ++i)
4381
- ++ calleeInfo.candidates [i].level ;
4381
+ calleeInfo.candidates [i].skipCurriedSelf = true ;
4382
4382
4383
4383
// TODO: Is there any reason to check for CC_NonLValueInOut here?
4384
4384
@@ -4668,7 +4668,7 @@ bool FailureDiagnosis::diagnoseArgumentGenericRequirements(
4668
4668
4669
4669
auto params = candidate.getParameters ();
4670
4670
SmallBitVector defaultMap =
4671
- computeDefaultMap (params, candidate.getDecl (), candidate.level );
4671
+ computeDefaultMap (params, candidate.getDecl (), candidate.skipCurriedSelf );
4672
4672
auto args = decomposeArgType (CS.getType (argExpr), argLabels);
4673
4673
4674
4674
SmallVector<ParamBinding, 4 > bindings;
@@ -5232,7 +5232,7 @@ static bool isViableOverloadSet(const CalleeCandidateInfo &CCI,
5232
5232
return true ;
5233
5233
};
5234
5234
5235
- auto defaultMap = computeDefaultMap (params, funcDecl, cand.level );
5235
+ auto defaultMap = computeDefaultMap (params, funcDecl, cand.skipCurriedSelf );
5236
5236
InputMatcher IM (params, defaultMap);
5237
5237
auto result = IM.match (numArgs, pairMatcher);
5238
5238
if (result == InputMatcher::IM_Succeeded)
@@ -5413,7 +5413,7 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
5413
5413
if (!calleeInfo.empty ()) {
5414
5414
auto &&cand = calleeInfo[0 ];
5415
5415
auto decl = cand.getDecl ();
5416
- if (decl && decl->isInstanceMember () && cand.level == 0 &&
5416
+ if (decl && decl->isInstanceMember () && ! cand.skipCurriedSelf &&
5417
5417
cand.getParameters ().size () == 1 )
5418
5418
isInstanceMethodAsCurriedMemberOnType = true ;
5419
5419
}
0 commit comments