Skip to content

Commit 29fad35

Browse files
authored
Merge pull request #65553 from xedin/move-leading-dot-fix-to-bindings
[CSBindings] NFC: Diagnose leading-dot inference failure when base type is…
2 parents db81593 + dba1b34 commit 29fad35

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,6 +2257,13 @@ TypeVariableBinding::fixForHole(ConstraintSystem &cs) const {
22572257
}
22582258
}
22592259

2260+
if (srcLocator->isLastElement<LocatorPathElt::MemberRefBase>()) {
2261+
auto *baseExpr = castToExpr<UnresolvedMemberExpr>(srcLocator->getAnchor());
2262+
ConstraintFix *fix = SpecifyBaseTypeForContextualMember::create(
2263+
cs, baseExpr->getName(), srcLocator);
2264+
return std::make_pair(fix, defaultImpact);
2265+
}
2266+
22602267
return None;
22612268
}
22622269

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6185,21 +6185,10 @@ bool ConstraintSystem::repairFailures(
61856185
}
61866186

61876187
case ConstraintLocator::UnresolvedMemberChainResult: {
6188-
// Ignore this mismatch if result is already a hole.
6189-
if (rhs->isPlaceholder())
6188+
// Ignore this mismatch if base or result is already a hole.
6189+
if (lhs->isPlaceholder() || rhs->isPlaceholder())
61906190
return true;
61916191

6192-
// The base is a placeholder, let's report an unknown base issue.
6193-
if (lhs->isPlaceholder()) {
6194-
auto *baseExpr =
6195-
castToExpr<UnresolvedMemberChainResultExpr>(anchor)->getChainBase();
6196-
6197-
auto *fix = SpecifyBaseTypeForContextualMember::create(
6198-
*this, baseExpr->getName(), getConstraintLocator(locator));
6199-
conversionsOrFixes.push_back(fix);
6200-
break;
6201-
}
6202-
62036192
if (repairViaOptionalUnwrap(*this, lhs, rhs, matchKind, conversionsOrFixes,
62046193
locator))
62056194
return true;

0 commit comments

Comments
 (0)