Skip to content

[Constraint system] Make solver less expression-centric, part N/M #29563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jan 31, 2020

Conversation

DougGregor
Copy link
Member

Further generalize the constraint solver's entry points to make it less tied to a single expression, which involves a number of steps:

  • Expand SolutionApplicationTarget so it can hold contextual type information, transformed function bodies, etc. This will capture all of the "top-level" things that we can solve in one shot
  • Generalize the expression-centric solve to work with a SolutionApplicationTarget and make the interface less stateful. We're not yet at the point where we can switch other clients over, but it's closer
  • Start hollowing out ExprTypeCheckListener, which is tied to the notion of a top-level expression. Focus on the easy parts of it to remove.

Make this type suitable for representing the result of solution application,
and do so.
Add the final conversion type and the flag indicating whether a given
expression is discarded to SolutionApplicationTarget, rather than 
separating the arguments to the solver implementation.
Now that we have a unified notion of a SolutionApplicationTarget, use it
to collapse 3 applySolution-ish functions into one.
Baby steps toward generalizing the expression-centric solver core.
…nFailed()

This function isn’t needed, because we can report the failure to the
caller directly rather than go through a callback.
Failures will be reported to clients; this callback is unnecessary.
It doesn’t do anything any more, because we’re handling error diagnostics
locally without callbacks. Also collapse typeCheckExpressionImpl() into
typeCheckExpression().
Only one client was using this, and its logic is trivially inlined into
appliedSolution().
Start cleaning up the main “solve” entry point for solving an expression
and applying the solution, so it handles arbitrary solution targets.
This is another small step that doesn’t do much on its own, but will help
with unifying the various places in the code base where we run the solver.
@DougGregor DougGregor requested a review from xedin January 31, 2020 06:06
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

Also, there's still a bunch of wanton mutation of parameters going on here. It'll get better as more of the larger thrust of the refactoring (to eliminate ExprTypeCheckListener and unify the different solve paths) occurs.

@DougGregor DougGregor merged commit 3e4e078 into swiftlang:master Jan 31, 2020
@DougGregor DougGregor deleted the generalize-solve branch January 31, 2020 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants