@@ -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 ();
@@ -4145,7 +4146,7 @@ static bool diagnoseRawRepresentableMismatch(CalleeCandidateInfo &CCI,
4145
4146
auto arguments = decomposeArgType (argType, argLabels);
4146
4147
4147
4148
auto bestMatchKind = RawRepresentableMismatch::NotApplicable;
4148
- const UncurriedCandidate *bestMatchCandidate = nullptr ;
4149
+ const OverloadCandidate *bestMatchCandidate = nullptr ;
4149
4150
KnownProtocolKind bestMatchProtocol;
4150
4151
size_t bestMatchIndex;
4151
4152
@@ -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))
@@ -4340,7 +4341,7 @@ bool FailureDiagnosis::diagnoseSubscriptErrors(SubscriptExpr *SE,
4340
4341
auto decomposedBaseType = decomposeArgType (baseType, {Identifier ()});
4341
4342
auto decomposedIndexType = decomposeArgType (indexType, argLabels);
4342
4343
calleeInfo.filterList (
4343
- [&](UncurriedCandidate cand) -> CalleeCandidateInfo::ClosenessResultTy {
4344
+ [&](OverloadCandidate cand) -> CalleeCandidateInfo::ClosenessResultTy {
4344
4345
// Classify how close this match is. Non-subscript decls don't match.
4345
4346
auto subscriptDecl = dyn_cast_or_null<SubscriptDecl>(cand.getDecl ());
4346
4347
if (!subscriptDecl ||
@@ -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
@@ -4402,7 +4402,7 @@ bool FailureDiagnosis::diagnoseSubscriptErrors(SubscriptExpr *SE,
4402
4402
// and more concrete expected type for this subscript decl, in order
4403
4403
// to diagnose a better error.
4404
4404
if (baseType && indexType->hasUnresolvedType ()) {
4405
- UncurriedCandidate cand = calleeInfo.candidates [0 ];
4405
+ auto cand = calleeInfo.candidates [0 ];
4406
4406
auto candType = baseType->getTypeOfMember (CS.DC ->getParentModule (),
4407
4407
cand.getDecl (), nullptr );
4408
4408
if (auto *candFunc = candType->getAs <FunctionType>()) {
@@ -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;
@@ -5125,8 +5125,8 @@ bool FailureDiagnosis::diagnoseSubscriptMisuse(ApplyExpr *callExpr) {
5125
5125
auto params = decomposeArgType (CS.getType (argExpr), argLabels);
5126
5126
using ClosenessPair = CalleeCandidateInfo::ClosenessResultTy;
5127
5127
5128
- candidateInfo.filterList ([&](UncurriedCandidate cand) -> ClosenessPair {
5129
- auto candFuncType = cand.getUncurriedFunctionType ();
5128
+ candidateInfo.filterList ([&](OverloadCandidate cand) -> ClosenessPair {
5129
+ auto candFuncType = cand.getFunctionType ();
5130
5130
if (!candFuncType)
5131
5131
return {CC_GeneralMismatch, {}};
5132
5132
@@ -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
}
@@ -5443,7 +5443,7 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
5443
5443
if (auto fn = fnType->getAs <AnyFunctionType>()) {
5444
5444
using Closeness = CalleeCandidateInfo::ClosenessResultTy;
5445
5445
5446
- calleeInfo.filterList ([&](UncurriedCandidate candidate) -> Closeness {
5446
+ calleeInfo.filterList ([&](OverloadCandidate candidate) -> Closeness {
5447
5447
auto resultType = candidate.getResultType ();
5448
5448
if (!resultType)
5449
5449
return {CC_GeneralMismatch, {}};
@@ -5679,7 +5679,7 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
5679
5679
return false ;
5680
5680
5681
5681
auto candidate = calleeInfo[0 ];
5682
- auto *fnType = candidate.getUncurriedFunctionType ();
5682
+ auto *fnType = candidate.getFunctionType ();
5683
5683
if (!fnType)
5684
5684
return false ;
5685
5685
@@ -7228,7 +7228,7 @@ bool FailureDiagnosis::visitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
7228
7228
// expected result type.
7229
7229
auto resultTy = candidateInfo[0 ].getResultType ();
7230
7230
if (!resultTy)
7231
- resultTy = candidateInfo[0 ].getUncurriedType ();
7231
+ resultTy = candidateInfo[0 ].getType ();
7232
7232
7233
7233
if (resultTy && !CS.getContextualType ()->is <UnboundGenericType>() &&
7234
7234
!CS.TC .isConvertibleTo (resultTy, CS.getContextualType (), CS.DC )) {
0 commit comments