Skip to content

Commit b008a4b

Browse files
author
Amritpan Kaur
committed
[CSSolver] Add supporting calls to pass around keyPath info
around the constraint system.
1 parent 8203b43 commit b008a4b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ Solution ConstraintSystem::finalize() {
188188
solution.keyPathComponentTypes.insert(keyPathComponentType);
189189
}
190190

191+
// Remember key paths.
192+
for (const auto &keyPaths : KeyPaths) {
193+
solution.KeyPaths.insert(keyPaths);
194+
}
195+
191196
// Remember contextual types.
192197
for (auto &entry : contextualTypes) {
193198
solution.contextualTypes.push_back({entry.first, entry.second.first});
@@ -304,6 +309,11 @@ void ConstraintSystem::applySolution(const Solution &solution) {
304309
nodeType.getSecond());
305310
}
306311

312+
// Add key paths.
313+
for (const auto &keypath : solution.KeyPaths) {
314+
KeyPaths.insert(keypath);
315+
}
316+
307317
// Add the contextual types.
308318
for (const auto &contextualType : solution.contextualTypes) {
309319
if (!getContextualTypeInfo(contextualType.first)) {
@@ -616,6 +626,7 @@ ConstraintSystem::SolverScope::SolverScope(ConstraintSystem &cs)
616626
numDefaultedConstraints = cs.DefaultedConstraints.size();
617627
numAddedNodeTypes = cs.addedNodeTypes.size();
618628
numAddedKeyPathComponentTypes = cs.addedKeyPathComponentTypes.size();
629+
numKeyPaths = cs.KeyPaths.size();
619630
numDisabledConstraints = cs.solverState->getNumDisabledConstraints();
620631
numFavoredConstraints = cs.solverState->getNumFavoredConstraints();
621632
numResultBuilderTransformed = cs.resultBuilderTransformed.size();
@@ -724,6 +735,9 @@ ConstraintSystem::SolverScope::~SolverScope() {
724735
}
725736
truncate(cs.addedKeyPathComponentTypes, numAddedKeyPathComponentTypes);
726737

738+
/// Remove any key path expressions.
739+
truncate(cs.KeyPaths, numKeyPaths);
740+
727741
/// Remove any builder transformed closures.
728742
truncate(cs.resultBuilderTransformed, numResultBuilderTransformed);
729743

0 commit comments

Comments
 (0)