@@ -788,8 +788,7 @@ bool ConstraintSystem::Candidate::solve(
788
788
};
789
789
790
790
// Allocate new constraint system for sub-expression.
791
- ConstraintSystem cs (TC, DC,
792
- ConstraintSystemFlags::ReturnAllDiscoveredSolutions);
791
+ ConstraintSystem cs (TC, DC, None);
793
792
794
793
// Cleanup after constraint system generation/solving,
795
794
// because it would assign types to expressions, which
@@ -1021,7 +1020,13 @@ void ConstraintSystem::shrink(Expr *expr) {
1021
1020
}
1022
1021
1023
1022
Expr *walkToExprPost (Expr *expr) override {
1024
- if (expr == PrimaryExpr) {
1023
+ auto isSrcOfPrimaryAssignment = [&](Expr *expr) -> bool {
1024
+ if (auto *AE = dyn_cast<AssignExpr>(PrimaryExpr))
1025
+ return expr == AE->getSrc ();
1026
+ return false ;
1027
+ };
1028
+
1029
+ if (expr == PrimaryExpr || isSrcOfPrimaryAssignment (expr)) {
1025
1030
// If this is primary expression and there are no candidates
1026
1031
// to be solved, let's not record it, because it's going to be
1027
1032
// solved regardless.
@@ -1031,14 +1036,14 @@ void ConstraintSystem::shrink(Expr *expr) {
1031
1036
auto contextualType = CS.getContextualType ();
1032
1037
// If there is a contextual type set for this expression.
1033
1038
if (!contextualType.isNull ()) {
1034
- Candidates.push_back (Candidate (CS, expr , contextualType,
1039
+ Candidates.push_back (Candidate (CS, PrimaryExpr , contextualType,
1035
1040
CS.getContextualTypePurpose ()));
1036
1041
return expr;
1037
1042
}
1038
1043
1039
1044
// Or it's a function application with other candidates present.
1040
1045
if (isa<ApplyExpr>(expr)) {
1041
- Candidates.push_back (Candidate (CS, expr ));
1046
+ Candidates.push_back (Candidate (CS, PrimaryExpr ));
1042
1047
return expr;
1043
1048
}
1044
1049
}
0 commit comments