[Sema][SR-14408] Increase the impact of missing member fix when member is on argument position

This commit is contained in:
LucianoAlmeida
2021-08-25 20:05:34 -03:00
parent 259cf54c52
commit b5dbb694cc
2 changed files with 17 additions and 1 deletions

View File

@@ -8251,6 +8251,13 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
if (instanceTy->isAny() || instanceTy->isAnyObject())
impact += 5;
// Increasing the impact for missing member in any argument position so it
// doesn't affect situations where there are another fixes involved.
auto *anchorExpr = getAsExpr(locator->getAnchor());
if (anchorExpr && isArgumentExpr(anchorExpr)) {
impact += 5;
}
if (recordFix(fix, impact))
return SolutionKind::Error;
@@ -8301,7 +8308,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
functionRefKind, locator,
/*includeInaccessibleMembers*/ true);
// If uwrapped type still couldn't find anything for a given name,
// If unwrapped type still couldn't find anything for a given name,
// let's fallback to a "not such member" fix.
if (result.ViableCandidates.empty() && result.UnviableCandidates.empty())
return fixMissingMember(origBaseTy, memberTy, locator);