Skip to content

[ConstraintSystem] Record originator constraint for each type variable binding #28752

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

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Dec 12, 2019

This helps with a couple of things:

  • Simplify PotentialBinding interface and its memory footprint;

  • Provide more contextual information when a binding gets
    attempted because it's possible to use locator of the binding
    as a source of assignment.

@xedin xedin requested a review from DougGregor December 12, 2019 19:43
@xedin
Copy link
Contributor Author

xedin commented Dec 12, 2019

/cc @hborla @LucianoPAlmeida

Unify all of the fields of `PotentialBinding` which have to do with
location information into a single field with is either a constraint
(for regular bindings) or constraint locator (for "holes").

This helps to reduce the amount of space used by `PotentialBinding`
 as well as propagate more contextual information when binding gets
 attempted.
…iness

Solver needs to attempt both escaping and non-escaping variants
to determine correct error location.
…match

Sometimes diagnostic needs both sides of the conversion e.g.
when there is an attempt to bind generic argument to non-escaping type.
…ostic

This is useful in some situations where access to type variable(s)
helps to diagnose the problem properly e.g. if it's a conversion
to generic parameter.
This gives diagnostic access to both sides of a conversion/binding
which makes it easier to diagnose errors associated with generic parameters.
Since `binding` has all of the required information now it's possible
to use its `locator` as a source of type variable assignment
(`Bind` constraint) in `TypeVariableBinding::attempt` which helps
to improve diagnostics.
@xedin xedin force-pushed the simplify-potential-binding branch from 01bcce9 to 87beea3 Compare December 12, 2019 20:44
@xedin
Copy link
Contributor Author

xedin commented Dec 12, 2019

@swift-ci please smoke test

@@ -1548,8 +1548,8 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
if (!shouldAttemptFixes())
return getTypeMatchFailure(locator);

auto *fix = MarkExplicitlyEscaping::create(
*this, getConstraintLocator(locator), func2);
auto *fix = MarkExplicitlyEscaping::create(*this, func1, func2,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!
That's exactly the diagnostic which was failing when I try to use the source locator as the binding locator, I definitely was missing something 😅

There was a single place where it was used to determine whether
a binding comes from an argument conversion constraint. Since
constraint locator is part of the binding now it's possible to
use it instead and remove unused accessor.
@xedin
Copy link
Contributor Author

xedin commented Dec 13, 2019

@swift-ci please smoke test

@xedin xedin merged commit 5ba2e59 into swiftlang:master Dec 13, 2019
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.

4 participants