Skip to content

Commit 40ca1ef

Browse files
committed
[Constraint solver] Eliminate ExprTypeCheckListener::foundSolution()
Only one client was using this, and its logic is trivially inlined into appliedSolution().
1 parent 5c6608f commit 40ca1ef

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,10 +2027,6 @@ bool ExprTypeCheckListener::builtConstraints(ConstraintSystem &cs, Expr *expr) {
20272027
return false;
20282028
}
20292029

2030-
Expr *ExprTypeCheckListener::foundSolution(Solution &solution, Expr *expr) {
2031-
return expr;
2032-
}
2033-
20342030
Expr *ExprTypeCheckListener::appliedSolution(Solution &solution, Expr *expr) {
20352031
return expr;
20362032
}
@@ -2158,8 +2154,6 @@ Type TypeChecker::typeCheckExpression(Expr *&expr, DeclContext *dc,
21582154

21592155
auto result = expr;
21602156
auto &solution = viable[0];
2161-
if (listener)
2162-
result = listener->foundSolution(solution, result);
21632157
if (!result)
21642158
return Type();
21652159

@@ -2578,16 +2572,13 @@ bool TypeChecker::typeCheckBinding(Pattern *&pattern, Expr *&initializer,
25782572
return false;
25792573
}
25802574

2581-
Expr *foundSolution(Solution &solution, Expr *expr) override {
2582-
// Figure out what type the constraints decided on.
2583-
auto ty = solution.simplifyType(initType);
2584-
initType = ty->getRValueType()->reconstituteSugar(/*recursive =*/false);
2585-
2586-
// Just keep going.
2587-
return expr;
2588-
}
2589-
25902575
Expr *appliedSolution(Solution &solution, Expr *expr) override {
2576+
{
2577+
// Figure out what type the constraints decided on.
2578+
auto ty = solution.simplifyType(initType);
2579+
initType = ty->getRValueType()->reconstituteSugar(/*recursive =*/false);
2580+
}
2581+
25912582
// Convert the initializer to the type of the pattern.
25922583
expr = solution.coerceToType(expr, initType, Locator);
25932584
if (!expr)

lib/Sema/TypeChecker.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,6 @@ class ExprTypeCheckListener {
305305
/// constraint system, or false otherwise.
306306
virtual bool builtConstraints(constraints::ConstraintSystem &cs, Expr *expr);
307307

308-
/// Callback invoked once a solution has been found.
309-
///
310-
/// The callback may further alter the expression, returning either a
311-
/// new expression (to replace the result) or a null pointer to indicate
312-
/// failure.
313-
virtual Expr *foundSolution(constraints::Solution &solution, Expr *expr);
314-
315308
/// Callback invokes once the chosen solution has been applied to the
316309
/// expression.
317310
///

0 commit comments

Comments
 (0)