Skip to content
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

[ConstraintSystem] Fix a logic error in computing potential bindings. #17317

Merged
merged 2 commits into from Jun 19, 2018
Merged

[ConstraintSystem] Fix a logic error in computing potential bindings. #17317

merged 2 commits into from Jun 19, 2018

Conversation

rudkx
Copy link
Member

@rudkx rudkx commented Jun 19, 2018

A change was made to attempt to use constraints that we have between
type variables to inform potential bindings, such that if we have:

   $T1 <: $T2

we would use $T1's bindings to add to the bindings of $T2. This is
only valid if we're adding bindings where $T1 is the supertype,
though, otherwise we could have the constraints:

  $T1 <: $T2
  $T1 <: X

imply that $T2 is a supertype of X, which doesn't make sense.

Fixes rdar://problem/40810000 (aka https://bugs.swift.org/browse/SR-7875).

A change was made to attempt to use constraints that we have between
type variables to inform potential bindings, such that if we have:
   $T1 <: $T2
we would use $T1's bindings to add to the bindings of $T2. This is
only valid if we're adding bindings where $T1 is the supertype,
though, otherwise we could have the constraints:
  $T1 <: $T2
  $T1 <: X
imply that $T2 is a supertype of X, which doesn't make sense.

Fixes rdar://problem/40810000 (aka https://bugs.swift.org/browse/SR-7875).
@rudkx rudkx requested a review from xedin June 19, 2018 01:35
@rudkx
Copy link
Member Author

rudkx commented Jun 19, 2018

@swift-ci Please smoke test

@rudkx rudkx requested a review from DougGregor June 19, 2018 01:35
Copy link
Member

@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, thanks @rudkx!

// to add Supertype bindings based on the relationship between
// our type variables.
if (binding.Kind != AllowedBindingKind::Exact
&& binding.Kind != AllowedBindingKind::Supertypes)
Copy link
Member

Choose a reason for hiding this comment

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

Only formatting nit - clang-format always leaves operators on at the end of the line, so in this case && wouldn't be moved done.

Copy link
Member Author

@rudkx rudkx Jun 19, 2018

Choose a reason for hiding this comment

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

Yes, this isn't formatted the same way that our current clang-format rules would format it. I think that's a good thing :).

My recollection is that there was a thread on this not long ago where there was some support for changing the clang-format rule for this since it's often easier to see what's going on when the operators are at the beginning of the continuation line.

We don't, AFAIK, have a rule about clang-formatting all changes, either (if we did, we'd probably make that a git post-receive hook).

Having said all that, we do have a rule that new code should be formatted consistently with surrounding code and in this case this would be an outlier, so I'll add another commit to fix this.

Copy link
Member

Choose a reason for hiding this comment

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

Interesting, always good to know the background!

@rudkx
Copy link
Member Author

rudkx commented Jun 19, 2018

@swift-ci Please test source compatibility

@rudkx
Copy link
Member Author

rudkx commented Jun 19, 2018

@swift-ci Please smoke test

@rudkx
Copy link
Member Author

rudkx commented Jun 19, 2018

@swift-ci Please test source compatibility

@rudkx rudkx merged commit 9f30ed6 into apple:master Jun 19, 2018
@rudkx rudkx deleted the fix-sr7875 branch June 19, 2018 07:10
Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

LGTM, thank you

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.

None yet

3 participants