[CS] Add a missing null check in repairFailures

If we fail to simplify the locator, such as in the
case where we have synthesized a missing call
argument, bail without trying to add a missing
call fix.

Resolves SR-12964.
Resolves rdar://64168162.
This commit is contained in:
Hamish Knight
2020-06-09 13:52:09 -07:00
parent f7fd83de3a
commit a48776705d
2 changed files with 11 additions and 3 deletions

View File

@@ -3047,11 +3047,12 @@ bool ConstraintSystem::repairFailures(
// default values, let's see whether error is related to missing
// explicit call.
if (fnType->getNumParams() > 0) {
auto anchor = simplifyLocatorToAnchor(getConstraintLocator(locator));
if (!anchor.is<Expr *>())
auto *loc = getConstraintLocator(locator);
auto *anchor = getAsExpr(simplifyLocatorToAnchor(loc));
if (!anchor)
return false;
auto overload = findSelectedOverloadFor(getAsExpr(anchor));
auto overload = findSelectedOverloadFor(anchor);
if (!(overload && overload->choice.isDecl()))
return false;