-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SR-11295] [Re-apply] Unnecessary Coercion explicitly same type coercion warning #27895
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
[SR-11295] [Re-apply] Unnecessary Coercion explicitly same type coercion warning #27895
Conversation
The significant changes are in 6a49ea3ac3c4b7277bcb9232e121930db0e756cf and 5816a59cb479a8802b6495e68aefd452f706e8cd. The rest is from the original PR :) |
5816a59
to
b73a305
Compare
04e4346
to
1ecdd76
Compare
36b1741
to
f383d9c
Compare
cc @xedin |
A couple of changes because of #28166 :) |
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.
Thank you for working on this, @LucianoPAlmeida! I have left some comments inline, sorry it took me a bit to take a look at this...
No worries, Thank you for taking the time to give feedback on this :) |
20db030
to
533af73
Compare
More detailed notes:
|
Sorry for the wait, @LucianoPAlmeida! This is in my queue for tomorrow. |
No problem @xedin, I know you guys are very busy :)) |
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.
Great progress! Changes follow the direction I had in mind the only additional thing we need is a new flag which would suppress warnings like that so tests are less noisy because some of them introduce redundant coercions intentionally.
lib/Sema/CSSimplify.cpp
Outdated
// binding, meaning the fixed type can come from a constraint. | ||
if (!hasRecordedTypeVariableBindingLocator(typeVar1)) | ||
recordTypeVariableBindingLocator(typeVar1, | ||
getConstraintLocator(locator)); |
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.
typeVar1
haven't been bound yet, why are we recording locator for it here? I think what you really trying to do here is has to be added to assignFixedType
maybe...
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.
Humm.. so we only record the binding on assignFixedType
or just if we didn't record it already on TypeVariableBinding::attempt
, I remember when I tried to record only all in assignFixedType
I had problems because we don't have the source locator there. It works if we pass the source locator as the bind locator like here 9e85a18, but it ends up breaking other diagnostics that rely on the other locator... maybe I didn't do this correctly. I'll get back to this as soon as possible.
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.
I think recording should only be done by assignFixedType
because that's the point which is supposed to be binding type variables. What we need to is provide Bind
constraint with correct "source" locator which fixed by #28752.
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.
Thank you @xedin I'm getting back to this, may have something soon :)
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.
Great! :)
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.
I think we have two options here: a. Try to add some special handling to
applySolutionWithFixes
which would detect re-typecheck and skip any warnings generated by the solver (I think it should be possible to archive by checking for presence ofSubExpressionDiagnostics
flag in constraint system options); b. Postpone these changes until after CSDiag is gone;
Ahh @xedin, also ... I just check for it on attempt
for this fix specifically, not in applySolutionFixes
because I didn't know how it would impact the tests(testing now) and if it breaks something I didn't want to fix all in this PR, so I check specific... but I can do it in another PR and fix all there. What do you think?
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.
@xedin Just finish rebasing/updating this with master :)
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.
Are you trying to say that this is ready for review again? :) FYI, there is a refresh icon on the side of each reviewer which allows to re-request the review after the changes have been made.
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.
Meanwhile, if you are looking for something to work on, there is FailureDiagnosis:: visitObjectLiteralExpr
which is waiting to be ported :)
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.
Are you trying to say that this is ready for review again? :) FYI, there is a refresh icon on the side of each reviewer which allows to re-request the review after the changes have been made.
Humm... I think the implementation itself is ready for review, but we stuck on the issue with the TupleElement
locator path. Maybe it could be reviewed and have some points to improve, but since it takes time, let's wait until we have this issue solved and it is ready to go.
I just wanted to ping you, and meant that since I updated it with master, the only thing left to get this ready is to try to solve the problem and I wanted to know if maybe there is something I can help working on to fix it so we can move this forward :)
Meanwhile, if you are looking for something to work on, there is FailureDiagnosis:: visitObjectLiteralExpr which is waiting to be ported :)
Awesome, I can take it meanwhile :)) Thank you!
@@ -1269,6 +1269,9 @@ class ConstraintSystem { | |||
using FixedRequirement = std::tuple<TypeBase *, RequirementKind, TypeBase *>; | |||
SmallVector<FixedRequirement, 4> FixedRequirements; | |||
|
|||
/// Intended to track information about type variable source binding locator. | |||
llvm::DenseMap<const TypeVariableType *, const ConstraintLocator *> TypeVariableBindings; |
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.
One more thing we need for this to work correct is to track how many bindings we have in each SolverScope
and rollback once it's done just like we do for overloads and other things, take a look at SolverScope
constructor/destructor located in CSSolver.cpp
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.
Sure, I'll take a look 👍
4e3cac0
to
16e8a40
Compare
This patch has grown to nearly 60 commits. Could you please squash this down? |
Sure @CodaFi :) I'll do it as soon as possible 👍 |
8340e75
to
16dee0d
Compare
No problem! |
b77b477
to
161cce3
Compare
…yCoercionFailure diagnostics
…ng RemoveUnnecessaryCoercion fix on match types
… source points to a tuple element.
…ssaryCoercion fix and adjusting some tests
…nFailure to use solution on diagnose()
…plicitTypeCoercion path
161cce3
to
b22b1b8
Compare
Re-apply reverted PR with fixes.
Re-opening the PR fixing the issues we had.
Also, a point to continue the discussion started in #27881 and #27877
cc @xedin @hborla