[CSSimplify] NFC: Perform assignments to a key path in a separate method

Previously key path type didn't have any requirements on their
root and value types but now that they do, we need a dedicated
place to perform an assignment and open/record all of the requirements.
This commit is contained in:
Pavel Yaskevich
2025-03-17 14:06:43 -07:00
parent f6c9177120
commit 6c22036931
2 changed files with 30 additions and 0 deletions

View File

@@ -4675,6 +4675,12 @@ ConstraintSystem::matchTypesBindTypeVar(
: getTypeMatchFailure(locator);
}
if (typeVar->getImpl().isKeyPathType()) {
return resolveKeyPath(typeVar, type, flags, locator)
? getTypeMatchSuccess()
: getTypeMatchFailure(locator);
}
assignFixedType(typeVar, type, /*updateState=*/true,
/*notifyInference=*/!flags.contains(TMF_BindingTypeVariable));
@@ -12257,6 +12263,15 @@ bool ConstraintSystem::resolveTapBody(TypeVariableType *typeVar,
return !generateConstraints(tapExpr);
}
bool ConstraintSystem::resolveKeyPath(TypeVariableType *typeVar,
Type contextualType,
TypeMatchOptions flags,
ConstraintLocatorBuilder locator) {
assignFixedType(typeVar, contextualType, /*updateState=*/true,
/*notifyInference=*/!flags.contains(TMF_BindingTypeVariable));
return true;
}
ConstraintSystem::SolutionKind
ConstraintSystem::simplifyDynamicTypeOfConstraint(
Type type1, Type type2,