[CSSimplify] Recording fix for keypath application root type mismatch

This commit is contained in:
Luciano Almeida
2020-04-21 17:46:16 -03:00
parent f18fe0960f
commit e17a934464

View File

@@ -3577,6 +3577,12 @@ bool ConstraintSystem::repairFailures(
break;
}
case ConstraintLocator::KeyPathRoot:
conversionsOrFixes.push_back(AllowKeyPathRootTypeMismatch::create(
*this, lhs, rhs, getConstraintLocator(locator)));
break;
case ConstraintLocator::FunctionArgument: {
auto *argLoc = getConstraintLocator(
locator.withPathElement(LocatorPathElt::SynthesizedArgument(0)));
@@ -7829,8 +7835,9 @@ ConstraintSystem::simplifyKeyPathApplicationConstraint(
rootTy = getFixedTypeRecursive(rootTy, flags, /*wantRValue=*/false);
auto matchRoot = [&](ConstraintKind kind) -> bool {
auto rootMatches = matchTypes(rootTy, kpRootTy, kind,
subflags, locator);
auto rootMatches =
matchTypes(rootTy, kpRootTy, kind, subflags,
locator.withPathElement(LocatorPathElt::KeyPathRoot()));
switch (rootMatches) {
case SolutionKind::Error:
return false;
@@ -9392,6 +9399,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
case FixKind::SpecifyBaseTypeForContextualMember:
case FixKind::CoerceToCheckedCast:
case FixKind::SpecifyObjectLiteralTypeImport:
case FixKind::AllowKeyPathRootTypeMismatch:
case FixKind::AllowCoercionToForceCast: {
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
}