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
Conversation
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).
@swift-ci Please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @rudkx!
lib/Sema/CSBindings.cpp
Outdated
// to add Supertype bindings based on the relationship between | ||
// our type variables. | ||
if (binding.Kind != AllowedBindingKind::Exact | ||
&& binding.Kind != AllowedBindingKind::Supertypes) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
@swift-ci Please test source compatibility |
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you
A change was made to attempt to use constraints that we have between
type variables to inform potential bindings, such that if we have:
we would use
$T1
's bindings to add to the bindings of$T2
. This isonly valid if we're adding bindings where
$T1
is the supertype,though, otherwise we could have the constraints:
imply that
$T2
is a supertype ofX
, which doesn't make sense.Fixes rdar://problem/40810000 (aka https://bugs.swift.org/browse/SR-7875).