-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema] FixIt for override func
that should be override var
and vice-versa
#63858
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
base: main
Are you sure you want to change the base?
Conversation
@AnthonyLatsis I have managed to get the |
How to Or if there is a way to print the modified form in the debugger? |
See https://github.com/apple/swift/blob/main/docs/Diagnostics.md#diagnostic-verifier |
Alright, I managed to add the fixit as well, is there anything else I must add to this fixit:
Maybe I should also probably also clear the body of the computed property | function with an addition of |
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 have left some comments inline and please add test-cases to test/decl/class/override.swift
and test/decl/inherit/override.swift
that check that newly added fix-its and notes.
Hey, thanks! @xedin |
Happy to help! Please press "re-request view" once you feel like that PR is ready for another round of review! |
@xedin What would be the right (or appropriate) way to add tests to the respective files you mentioned? |
All new tests are usually appended to the end of the test file, you should mention Github issue and/or radar number and wrap in either do or func declarations to avoid polluting global namespace with names that are local to tests. |
Alright! |
The |
The commands that are run for a given test file are usually specified at the top of the file using |
I am aware of running tests, as I had done them previously in my pull requests via this command:
But regarding the flags, I thought some extra work was needed as this is the first time I am adding test cases, my doubt was whether I should use certain So what would be the appropriate command to execute, let's say, for the file Would it be the same way as the command I used earlier (mentioned on top of this comment)? |
If the |
Ahh I see! Thanks! |
@xedin Could you please review this, I have mentioned few in line comments as well to describe certain issues. |
c9abc91
to
b01568a
Compare
16b3f09
to
722c9ce
Compare
f4b3c44
to
d2a229a
Compare
@xedin |
I don’t have any other suggestions besides running your changes under debugger and trying to figure out the root cause of the crash, the approach we have discussed should be sound, it’s the a matter of figuring out how exactly to use the APIs. |
d2a229a
to
57327c6
Compare
@Rajveer100 Are you still working on this? |
Been a while since I last worked on this, getting back to it :) |
override func
that should be override var
and vice-versa
57327c6
to
2792c31
Compare
@xedin |
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 a better approach is to handle this case in OverrideMatcher
(where name lookup is already done for us) during OverrideCheckingAttempt::BaseName
, and to ignore any other differences between the two declarations. Just always emit a tailored diagnostic for var vs. func, and leave the fix-its for another time. Quality fix-its are a deeper rabbit hole as things stand because the current logic is both exclusive and dependent on declaration kind equality, and there are plenty of rules aside from type matching for whether one property or method is a valid override of another.
That said, a great improvement to your current change would be to extract the diagnosis into a function.
…ce-versa Resolves swiftlang#57499 This adds `override_property_not_method` and `override_method_not_property` notes by performing a member lookup for the respective diagnostics.
2792c31
to
127bc79
Compare
Fixes #57499
This adds
override_property_not_method
andoverride_method_not_property
notes by performinga member lookup for the respective diagnostics.