Skip to content

Constraint simplification cleanups #21818

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 3 commits into from
Jan 13, 2019

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Jan 12, 2019

  • We can now solve a BindParam when both sides are type variables
  • We can now solve a Bind when both sides are type variables with different lvalue-ness

Fixes rdar://problem/45511838, https://bugs.swift.org/browse/SR-9068.

@slavapestov slavapestov force-pushed the constraint-solver-cleanups branch from b6b3da6 to c510ea4 Compare January 12, 2019 04:21
@slavapestov slavapestov requested a review from xedin January 12, 2019 04:21
@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@xedin I'm slowly untangling more code around InOutType and LValueType... also with these changes I observed a very small reduction in number of constraints, etc. But not nearly enough to measure.

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. FYI @rudkx and I mostly shy away from using Bind too much because (sometimes) it merges types too early and binding calculation code misses some potential bindings as a result, or (I saw that at least ones) causes infinite recursion because of isBindable check re-creates bind constraint infinitely if it fails.

@slavapestov
Copy link
Contributor Author

@xedin Is it possible that something else was fixed along the way? The only remaining uses of Equal are in keypaths.

@slavapestov
Copy link
Contributor Author

slavapestov commented Jan 12, 2019

@xedin The commit "Sema: Solve Bind constraints involving to two variables of different lvalue-ness" fixes https://bugs.swift.org/browse/SR-9068

@xedin
Copy link
Contributor

xedin commented Jan 12, 2019

@slavapestov Most likely yes, we had a bunch of bind constraints introduced by hacks in PreCheckExpression and other places like contractEdges, which got fixed at some point...

…lvalue-ness

The restriction here only applies to Equal constraints.

Fixes <rdar://problem/45511838>, <https://bugs.swift.org/browse/SR-9068>.
- Avoid creating an unnecessary type variable
- Even if both sides are type variables we can solve them if the LHS cannot
  bind to an InOut or the RHS cannot bind to an LValue; in this case the two
  types are identical and we can merge them
@slavapestov slavapestov force-pushed the constraint-solver-cleanups branch from c510ea4 to 5f4933b Compare January 12, 2019 23:05
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov force-pushed the constraint-solver-cleanups branch from 5f4933b to 52c1c8c Compare January 12, 2019 23:18
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

1 similar comment
@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

The failure is a UPASS because the bug was fixed.

@slavapestov slavapestov merged commit 374efd1 into swiftlang:master Jan 13, 2019
jrose-apple added a commit to jrose-apple/swift-source-compat-suite that referenced this pull request Jan 14, 2019
jrose-apple added a commit to swiftlang/swift-source-compat-suite that referenced this pull request Jan 14, 2019
@jrose-apple
Copy link
Contributor

Updated the source compat suite. Next time, can you get that too when you merge a fix? :-)

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.

3 participants