mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #80081 from xedin/rdar-143161190
[CSSimplify] Open key path type before assignment to its record requirements
This commit is contained in:
@@ -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,30 @@ bool ConstraintSystem::resolveTapBody(TypeVariableType *typeVar,
|
||||
return !generateConstraints(tapExpr);
|
||||
}
|
||||
|
||||
bool ConstraintSystem::resolveKeyPath(TypeVariableType *typeVar,
|
||||
Type contextualType,
|
||||
TypeMatchOptions flags,
|
||||
ConstraintLocatorBuilder locator) {
|
||||
// Key path types recently gained Copyable, Escapable requirements.
|
||||
// The solver cannot account for that during inference because Root
|
||||
// and Value types are required to be only resolved enough to infer
|
||||
// a capability of a key path itself.
|
||||
if (auto *BGT = contextualType->getAs<BoundGenericType>()) {
|
||||
auto keyPathTy = openUnboundGenericType(
|
||||
BGT->getDecl(), BGT->getParent(), locator, /*isTypeResolution=*/false);
|
||||
|
||||
assignFixedType(
|
||||
typeVar, keyPathTy, /*updateState=*/true,
|
||||
/*notifyInference=*/!flags.contains(TMF_BindingTypeVariable));
|
||||
addConstraint(ConstraintKind::Equal, keyPathTy, contextualType, locator);
|
||||
return true;
|
||||
}
|
||||
|
||||
assignFixedType(typeVar, contextualType, /*updateState=*/true,
|
||||
/*notifyInference=*/!flags.contains(TMF_BindingTypeVariable));
|
||||
return true;
|
||||
}
|
||||
|
||||
ConstraintSystem::SolutionKind
|
||||
ConstraintSystem::simplifyDynamicTypeOfConstraint(
|
||||
Type type1, Type type2,
|
||||
|
||||
Reference in New Issue
Block a user