-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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-15176] Fixit for override func
that should be override var
#57499
Comments
Comment by jiaren wang (JIRA) I would like give a shot on this. Could I get some hint? |
If I understand it correctly, the idea it here https://github.com/apple/swift/blob/a3c7d6c13984d884ccce80df88b950f0723a3af0/lib/Sema/TypeCheckDeclOverride.cpp#L540 somehow try to detect cases where you have a property trying to override a no-args function on base class or vice versa and try to provide a fix-it to provide a fix it for making one into another. For example, the fix-it offered will make the func in the example be class D: C {
- override func canBecomeFirstResponder() -> Bool {
- }
+ override var canBecomeFirstResponder: Bool {
+ }
} Since the override attempt have the same name and the same is a no-args function that produce the same result as the base class property (Bool). |
Swift Mentorship program mentee here, trying to contribute for the first time. Will dive deeper and work on this 😁 |
Hello @AnthonyLatsis - is this issue still open, can I give it a shot? Thanks! |
You’re welcome to! Make sure it still reproduces though. Want we to assign you? |
I got busier and did not complete it yet, but I did make progress on this and was planning on opening the PR soon. |
Update: I don’t think I’ll keep working on this anytime soon, I’m unassigning myself |
Let's try this! |
Hey @LucianoPAlmeida @AnthonyLatsis , I managed to find the error call site: (Case 1: When the method is overridden instead of the property)
(Case 2: When the property is overridden instead of the method)
So I think fixing the actual issue remains. I will try to do it! |
@AnthonyLatsis I have a little off-topic issue, I have come across this earlier too, what I did was to delete my workspace and again create it, but is there any other solution to this?
|
PS: Rebuilding fixed the problem! |
This means the binary module format version associated with the just-built compiler is different than the one that was used to serialize the Standard Library (the |
Yes, also one more thing, I am suddenly encountering problems with (Some of the text is white, while some of them green, and some are showing few function type hints, not all) |
I have always seen these functional issues come up randomly when navigating the code base in Xcode. They usually get worse the older and more outdated the generated project becomes. Re-generating the projects after every checkout is probably the right answer, but I wouldn’t know for certain: I am too lazy to always keep the generated projects in sync, and tend to fall back to searching or spawning tabs whenever these issues show up. |
Also, are there any |
Like in this issue, I will have to find a match for the function parameter and its declaration in the parent class, to correctly identify whether this override can be fixed...same goes for the property... |
There is a little bit of info here |
Hey thanks a lot @LucianoPAlmeida! Looks like Swift Forums is a good place for asking such doubts! |
There is a compiler category on the forums where you can ask more general questions about development in the compiler. |
Cool! |
What do you mean by "type hint"? Code completion hints?
I do not know of any detailed write-ups on the AST design or the parts of semantic analysis that do not involve subtle and complex algorithms among our docs. This is where the inline documentation and comments come in handy. But we do have a list of external resources, many of which I found very helpful back in the day, with many more yet to read. Check out the article by Slava Pestov about how things are represented in the compiler. |
Thanks! @AnthonyLatsis Why was this issue closed and re opened? |
I have added the notes in the diagnostic file, I hope the changes are relatively fine: |
Have you tested them? Please open a pull request if you want your changes to be reviewed. |
Coming soon! |
I have one question, regarding the |
I finally managed to do it! I just need to provide a fixit now! Here is the output:
|
Swift does not have multiple inheritance. |
Oops! My bad! I misinterpreted it with |
… vice-versa Fixes Issue swiftlang#57499
… vice-versa Fixes Issue swiftlang#57499
… vice-versa Fixes Issue swiftlang#57499
… vice-versa Fixes Issue swiftlang#57499
… vice-versa Fixes Issue swiftlang#57499
Hi @CodaFi. I'm working in a full-stack development cohort with a requirement for an open source contribution. I would love to try this one as my first one as I have an interest in learning Swift. |
@wesleykebrown Assigned you. |
Additional Detail from JIRA
md5: b17661d61829d04b65f822d78b07388a
Issue Description:
Consider
We should add a special case to
diagnoseGeneralOverrideFailure
that tries to see if it can correct no-args FuncDecls to VarDecls and vice-versa.The text was updated successfully, but these errors were encountered: