mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #26749 from DougGregor/key-path-extra-type-variables
[Constraint solver] Tie together all of the type variables in a key path
This commit is contained in:
@@ -5714,11 +5714,13 @@ ConstraintSystem::simplifyOpenedExistentialOfConstraint(
|
||||
}
|
||||
|
||||
ConstraintSystem::SolutionKind
|
||||
ConstraintSystem::simplifyKeyPathConstraint(Type keyPathTy,
|
||||
Type rootTy,
|
||||
Type valueTy,
|
||||
TypeMatchOptions flags,
|
||||
ConstraintLocatorBuilder locator) {
|
||||
ConstraintSystem::simplifyKeyPathConstraint(
|
||||
Type keyPathTy,
|
||||
Type rootTy,
|
||||
Type valueTy,
|
||||
ArrayRef<TypeVariableType *> componentTypeVars,
|
||||
TypeMatchOptions flags,
|
||||
ConstraintLocatorBuilder locator) {
|
||||
auto subflags = getDefaultDecompositionOptions(flags);
|
||||
// The constraint ought to have been anchored on a KeyPathExpr.
|
||||
auto keyPath = cast<KeyPathExpr>(locator.getBaseLocator()->getAnchor());
|
||||
@@ -5940,7 +5942,8 @@ done:
|
||||
} else {
|
||||
addUnsolvedConstraint(Constraint::create(*this, ConstraintKind::KeyPath,
|
||||
keyPathTy, rootTy, valueTy,
|
||||
locator.getBaseLocator()));
|
||||
locator.getBaseLocator(),
|
||||
componentTypeVars));
|
||||
}
|
||||
return SolutionKind::Solved;
|
||||
}
|
||||
@@ -7448,18 +7451,22 @@ ConstraintSystem::addKeyPathApplicationConstraint(Type keypath,
|
||||
}
|
||||
|
||||
void
|
||||
ConstraintSystem::addKeyPathConstraint(Type keypath,
|
||||
Type root, Type value,
|
||||
ConstraintLocatorBuilder locator,
|
||||
bool isFavored) {
|
||||
ConstraintSystem::addKeyPathConstraint(
|
||||
Type keypath,
|
||||
Type root, Type value,
|
||||
ArrayRef<TypeVariableType *> componentTypeVars,
|
||||
ConstraintLocatorBuilder locator,
|
||||
bool isFavored) {
|
||||
switch (simplifyKeyPathConstraint(keypath, root, value,
|
||||
componentTypeVars,
|
||||
TMF_GenerateConstraints,
|
||||
locator)) {
|
||||
case SolutionKind::Error:
|
||||
if (shouldAddNewFailingConstraint()) {
|
||||
auto c = Constraint::create(*this, ConstraintKind::KeyPath,
|
||||
keypath, root, value,
|
||||
getConstraintLocator(locator));
|
||||
getConstraintLocator(locator),
|
||||
componentTypeVars);
|
||||
if (isFavored) c->setFavored();
|
||||
addNewFailingConstraint(c);
|
||||
}
|
||||
@@ -7640,7 +7647,7 @@ ConstraintSystem::simplifyConstraint(const Constraint &constraint) {
|
||||
case ConstraintKind::KeyPath:
|
||||
return simplifyKeyPathConstraint(
|
||||
constraint.getFirstType(), constraint.getSecondType(),
|
||||
constraint.getThirdType(),
|
||||
constraint.getThirdType(), constraint.getTypeVariables(),
|
||||
None, constraint.getLocator());
|
||||
|
||||
case ConstraintKind::KeyPathApplication:
|
||||
|
||||
Reference in New Issue
Block a user