[CSBindings] Diagnose leading-dot inference failure when base type is attempted as placeholder

Diagnose base inference failure only if base gets inferred to be
a placeholder, any transitive placeholder inference points to the
problem being elsewhere.
This commit is contained in:
Pavel Yaskevich
2023-04-28 09:23:23 -07:00
committed by Pavel Yaskevich
parent d445a18a32
commit dba1b3436a
2 changed files with 9 additions and 13 deletions

View File

@@ -6185,21 +6185,10 @@ bool ConstraintSystem::repairFailures(
}
case ConstraintLocator::UnresolvedMemberChainResult: {
// Ignore this mismatch if result is already a hole.
if (rhs->isPlaceholder())
// Ignore this mismatch if base or result is already a hole.
if (lhs->isPlaceholder() || rhs->isPlaceholder())
return true;
// The base is a placeholder, let's report an unknown base issue.
if (lhs->isPlaceholder()) {
auto *baseExpr =
castToExpr<UnresolvedMemberChainResultExpr>(anchor)->getChainBase();
auto *fix = SpecifyBaseTypeForContextualMember::create(
*this, baseExpr->getName(), getConstraintLocator(locator));
conversionsOrFixes.push_back(fix);
break;
}
if (repairViaOptionalUnwrap(*this, lhs, rhs, matchKind, conversionsOrFixes,
locator))
return true;