Skip to content

Commit b3c12ca

Browse files
committed
[CS] NFC: Move SolverSnapshot::applySolution into the cpp file
1 parent 0ea42cf commit b3c12ca

File tree

2 files changed

+31
-29
lines changed

2 files changed

+31
-29
lines changed

lib/Sema/CSStep.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,3 +1091,33 @@ void ConjunctionStep::restoreOuterState(const Score &solutionScore) const {
10911091
constraint.setActive(true);
10921092
}
10931093
}
1094+
1095+
void ConjunctionStep::SolverSnapshot::applySolution(const Solution &solution) {
1096+
CS.applySolution(solution);
1097+
1098+
if (!CS.shouldAttemptFixes())
1099+
return;
1100+
1101+
// If inference succeeded, we are done.
1102+
auto score = solution.getFixedScore();
1103+
if (score.Data[SK_Fix] == 0)
1104+
return;
1105+
1106+
// If this conjunction represents a closure and inference
1107+
// has failed, let's bind all of unresolved type variables
1108+
// in its interface type to holes to avoid extraneous
1109+
// fixes produced by outer context.
1110+
1111+
auto locator = Conjunction->getLocator();
1112+
if (locator->directlyAt<ClosureExpr>()) {
1113+
auto closureTy =
1114+
CS.getClosureType(castToExpr<ClosureExpr>(locator->getAnchor()));
1115+
1116+
CS.simplifyType(closureTy).visit([&](Type componentTy) {
1117+
if (auto *typeVar = componentTy->getAs<TypeVariableType>()) {
1118+
CS.assignFixedType(
1119+
typeVar, PlaceholderType::get(CS.getASTContext(), typeVar));
1120+
}
1121+
});
1122+
}
1123+
}

lib/Sema/CSStep.h

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -895,35 +895,7 @@ class ConjunctionStep : public BindingStep<ConjunctionElementProducer> {
895895
CG.addConstraint(&constraint);
896896
}
897897

898-
void applySolution(const Solution &solution) {
899-
CS.applySolution(solution);
900-
901-
if (!CS.shouldAttemptFixes())
902-
return;
903-
904-
// If inference succeeded, we are done.
905-
auto score = solution.getFixedScore();
906-
if (score.Data[SK_Fix] == 0)
907-
return;
908-
909-
// If this conjunction represents a closure and inference
910-
// has failed, let's bind all of unresolved type variables
911-
// in its interface type to holes to avoid extraneous
912-
// fixes produced by outer context.
913-
914-
auto locator = Conjunction->getLocator();
915-
if (locator->directlyAt<ClosureExpr>()) {
916-
auto closureTy =
917-
CS.getClosureType(castToExpr<ClosureExpr>(locator->getAnchor()));
918-
919-
CS.simplifyType(closureTy).visit([&](Type componentTy) {
920-
if (auto *typeVar = componentTy->getAs<TypeVariableType>()) {
921-
CS.assignFixedType(
922-
typeVar, PlaceholderType::get(CS.getASTContext(), typeVar));
923-
}
924-
});
925-
}
926-
}
898+
void applySolution(const Solution &solution);
927899
};
928900

929901
/// Best solution solver reached so far.

0 commit comments

Comments
 (0)