Skip to content

Commit 36031f3

Browse files
author
Amritpan Kaur
committed
[CSSimplify] Prevent contextual type failure fix record
1 parent 9e4f23b commit 36031f3

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5187,18 +5187,12 @@ bool ConstraintSystem::repairFailures(
51875187
// fix-up here unless last component has already a invalid type or
51885188
// instance fix recorded.
51895189
if (auto *kpExpr = getAsExpr<KeyPathExpr>(anchor)) {
5190-
auto i = kpExpr->getComponents().size() - 1;
5191-
auto lastCompLoc = getConstraintLocator(
5192-
locator.withPathElement(LocatorPathElt::KeyPathComponent(i)));
5193-
if (hasFixFor(lastCompLoc, FixKind::AllowTypeOrInstanceMember))
5194-
return true;
5195-
5196-
auto lastComponentType = lhs->lookThroughAllOptionalTypes();
5197-
auto keyPathResultType = rhs->lookThroughAllOptionalTypes();
5198-
5199-
// Propagate contextual information from/to keypath result type.
5200-
(void)matchTypes(lastComponentType, keyPathResultType, matchKind,
5201-
TMF_ApplyingFix, getConstraintLocator(locator));
5190+
if (isKnownKeyPathType(lhs) && isKnownKeyPathType(rhs)) {
5191+
// If we have keypath capabilities for both sides and one of the bases
5192+
// is unresolved, it is too early to record fix.
5193+
if (hasConversionOrRestriction(ConversionRestrictionKind::DeepEquality))
5194+
return false;
5195+
}
52025196

52035197
conversionsOrFixes.push_back(IgnoreContextualType::create(
52045198
*this, lhs, rhs, getConstraintLocator(locator)));

0 commit comments

Comments
 (0)