Skip to content

Commit 6273941

Browse files
committed
[Constraint solver] Centralize solution-application logic somewhat.
In anticipation of eliminating this solution-application logic, centralize to application of solutions back to the constraint system for the purpose of applying the solution to update ASTs.
1 parent c63076e commit 6273941

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

lib/Sema/CSApply.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7334,10 +7334,6 @@ namespace {
73347334
/// Emit the fixes computed as part of the solution, returning true if we were
73357335
/// able to emit an error message, or false if none of the fixits worked out.
73367336
bool ConstraintSystem::applySolutionFixes(const Solution &solution) {
7337-
// First transfer all of the deduced information back
7338-
// to the constraint system.
7339-
applySolution(solution);
7340-
73417337
/// Collect the fixes on a per-expression basis.
73427338
llvm::SmallDenseMap<Expr *, SmallVector<ConstraintFix *, 4>> fixesPerExpr;
73437339
for (auto *fix : solution.Fixes) {
@@ -7392,11 +7388,6 @@ Expr *ConstraintSystem::applySolution(Solution &solution, Expr *expr,
73927388
Type convertType,
73937389
bool discardedExpr,
73947390
bool skipClosures) {
7395-
// Add the node types back.
7396-
for (auto &nodeType : solution.addedNodeTypes) {
7397-
setType(nodeType.first, nodeType.second);
7398-
}
7399-
74007391
// If any fixes needed to be applied to arrive at this solution, resolve
74017392
// them to specific expressions.
74027393
if (!solution.Fixes.empty()) {

lib/Sema/ConstraintSystem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,9 @@ class ConstraintSystem {
17071707
/// constraint system for further exploration.
17081708
void applySolution(const Solution &solution);
17091709

1710+
// FIXME: Allows the type checker to apply solutions.
1711+
friend class swift::TypeChecker;
1712+
17101713
/// Emit the fixes computed as part of the solution, returning true if we were
17111714
/// able to emit an error message, or false if none of the fixits worked out.
17121715
bool applySolutionFixes(const Solution &solution);

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,6 +2261,9 @@ Type TypeChecker::typeCheckExpressionImpl(Expr *&expr, DeclContext *dc,
22612261
if (!result)
22622262
return Type();
22632263

2264+
// Apply this solution to the constraint system.
2265+
cs.applySolution(solution);
2266+
22642267
// Apply the solution to the expression.
22652268
result = cs.applySolution(
22662269
solution, result, convertType.getType(),

0 commit comments

Comments
 (0)