Skip to content

Commit d3205b2

Browse files
committed
[ConstraintSystem] Remove UR_LabelMismatch overload unavailability reason
This helps with: - Diagnostics because solver would get more choices to work with in diagnostic mode; - Avoid adding the same overload multiple times (retry after label mismatch and no viable candidates); - Unify overload handling/filtering in `simplfyAppliedOverloads`.
1 parent da38e25 commit d3205b2

File tree

3 files changed

+0
-48
lines changed

3 files changed

+0
-48
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,6 @@ void FailureDiagnosis::diagnoseUnviableLookupResults(
741741
return;
742742

743743
switch (firstProblem) {
744-
case MemberLookupResult::UR_LabelMismatch:
745744
case MemberLookupResult::UR_WritableKeyPathOnReadOnlyMember:
746745
case MemberLookupResult::UR_ReferenceWritableKeyPathOnMutatingMember:
747746
case MemberLookupResult::UR_KeyPathWithAnyObjectRootType:

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4173,24 +4173,6 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
41734173
if (!instanceTy->mayHaveMembers())
41744174
return result;
41754175

4176-
// If we have a simple name, determine whether there are argument
4177-
// labels we can use to restrict the set of lookup results.
4178-
Optional<ArgumentLabelState> argumentLabels;
4179-
if (memberName.isSimpleName()) {
4180-
argumentLabels = getArgumentLabels(*this,
4181-
ConstraintLocatorBuilder(memberLocator));
4182-
4183-
// If we're referencing AnyObject and we have argument labels, put
4184-
// the argument labels into the name: we don't want to look for
4185-
// anything else, because the cost of the general search is so
4186-
// high.
4187-
if (baseObjTy->isAnyObject() && argumentLabels) {
4188-
memberName = DeclName(TC.Context, memberName.getBaseName(),
4189-
argumentLabels->Labels);
4190-
argumentLabels.reset();
4191-
}
4192-
}
4193-
41944176
// Look for members within the base.
41954177
LookupResult &lookup = lookupMember(instanceTy, memberName);
41964178

@@ -4226,7 +4208,6 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
42264208
bridgedType = classType;
42274209
}
42284210
}
4229-
bool labelMismatch = false;
42304211

42314212
// Local function that adds the given declaration if it is a
42324213
// reasonable choice.
@@ -4291,20 +4272,6 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
42914272
hasInstanceMethods = true;
42924273
}
42934274

4294-
// If the argument labels for this result are incompatible with
4295-
// the call site, skip it.
4296-
// FIXME: The subscript check here forces the use of the
4297-
// function-application simplification logic to handle labels.
4298-
if (argumentLabels &&
4299-
(!candidate.isDecl() || !isa<SubscriptDecl>(candidate.getDecl())) &&
4300-
!areConservativelyCompatibleArgumentLabels(
4301-
candidate, argumentLabels->Labels,
4302-
argumentLabels->HasTrailingClosure)) {
4303-
labelMismatch = true;
4304-
result.addUnviable(candidate, MemberLookupResult::UR_LabelMismatch);
4305-
return;
4306-
}
4307-
43084275
// If our base is an existential type, we can't make use of any
43094276
// member whose signature involves associated types.
43104277
if (instanceTy->isExistentialType()) {
@@ -4494,8 +4461,6 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
44944461
};
44954462

44964463
// Add all results from this lookup.
4497-
retry_after_fail:
4498-
labelMismatch = false;
44994464
for (auto result : lookup)
45004465
addChoice(getOverloadChoice(result.getValueDecl(),
45014466
/*isBridged=*/false,
@@ -4603,14 +4568,6 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
46034568
}
46044569
}
46054570

4606-
// If we rejected some possibilities due to an argument-label
4607-
// mismatch and ended up with nothing, try again ignoring the
4608-
// labels. This allows us to perform typo correction on the labels.
4609-
if (result.ViableCandidates.empty() && labelMismatch && shouldAttemptFixes()){
4610-
argumentLabels.reset();
4611-
goto retry_after_fail;
4612-
}
4613-
46144571
// If we have no viable or unviable candidates, and we're generating,
46154572
// diagnostics, rerun the query with inaccessible members included, so we can
46164573
// include them in the unviable candidates list.
@@ -4855,7 +4812,6 @@ fixMemberRef(ConstraintSystem &cs, Type baseTy,
48554812
: nullptr;
48564813
}
48574814

4858-
case MemberLookupResult::UR_LabelMismatch:
48594815
// TODO(diagnostics): Add a new fix that is suggests to
48604816
// add `subscript(dynamicMember: {Writable}KeyPath<T, U>)`
48614817
// overload here, that would help if such subscript has

lib/Sema/ConstraintSystem.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -886,9 +886,6 @@ struct MemberLookupResult {
886886

887887
/// This enum tracks reasons why a candidate is not viable.
888888
enum UnviableReason {
889-
/// Argument labels don't match.
890-
UR_LabelMismatch,
891-
892889
/// This uses a type like Self in its signature that cannot be used on an
893890
/// existential box.
894891
UR_UnavailableInExistential,

0 commit comments

Comments
 (0)