Skip to content

Commit a8baec6

Browse files
committed
[CSSimplify] Open key path type before assignment to its record requirements
`Root` and `Value` generic parameters now have conformance requirements which we need to account for post-binding inference.
1 parent 6c22036 commit a8baec6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12267,6 +12267,21 @@ bool ConstraintSystem::resolveKeyPath(TypeVariableType *typeVar,
1226712267
Type contextualType,
1226812268
TypeMatchOptions flags,
1226912269
ConstraintLocatorBuilder locator) {
12270+
// Key path types recently gained Copyable, Escapable requirements.
12271+
// The solver cannot account for that during inference because Root
12272+
// and Value types are required to be only resolved enough to infer
12273+
// a capability of a key path itself.
12274+
if (auto *BGT = contextualType->getAs<BoundGenericType>()) {
12275+
auto keyPathTy = openUnboundGenericType(
12276+
BGT->getDecl(), BGT->getParent(), locator, /*isTypeResolution=*/false);
12277+
12278+
assignFixedType(
12279+
typeVar, keyPathTy, /*updateState=*/true,
12280+
/*notifyInference=*/!flags.contains(TMF_BindingTypeVariable));
12281+
addConstraint(ConstraintKind::Equal, keyPathTy, contextualType, locator);
12282+
return true;
12283+
}
12284+
1227012285
assignFixedType(typeVar, contextualType, /*updateState=*/true,
1227112286
/*notifyInference=*/!flags.contains(TMF_BindingTypeVariable));
1227212287
return true;

0 commit comments

Comments
 (0)