File tree Expand file tree Collapse file tree 2 files changed +31
-29
lines changed Expand file tree Collapse file tree 2 files changed +31
-29
lines changed Original file line number Diff line number Diff line change @@ -1091,3 +1091,33 @@ void ConjunctionStep::restoreOuterState(const Score &solutionScore) const {
1091
1091
constraint.setActive (true );
1092
1092
}
1093
1093
}
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
+ }
Original file line number Diff line number Diff line change @@ -895,35 +895,7 @@ class ConjunctionStep : public BindingStep<ConjunctionElementProducer> {
895
895
CG.addConstraint (&constraint);
896
896
}
897
897
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);
927
899
};
928
900
929
901
// / Best solution solver reached so far.
You can’t perform that action at this time.
0 commit comments