-
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-13388] Add Fix-Its to "override" mismatch #55828
Comments
@swift-ci create |
Comment by CaoMing (JIRA) I am interested in implementing this🙂 |
Sure thing. Check out our README for instructions on how to understand the workflow of submitting a PR and building the compiler. In this particular case, you can check which parts of the compiler emit the error by searching for the error string and working backwards from there (error string -> error name -> places which emit the error). Once you find that, you'll need to see which potential methods could've been over-ridden (but aren't because of the type mismatch). There may be zero or more "matches". The zero match case will not require any fix-its. The one match case will have one fix-it (search for 1. If there are multiple matches, show multiple fix-its. This may get overwhelming if there are too many matches. |
Comment by CaoMing (JIRA) Very detailed guidance, thank you very much |
> Once you find that, you'll need to see which potential methods could've been over-ridden (but aren't because of the type mismatch). This should already be available in some form. Override matching does a name lookup to find candidates, and then filters this list by argument label and type. You can preserve the original list, and use it to emit diagnostics if the final set of candidates is empty. |
Comment by CaoMing (JIRA) class Base { class C: Base { } In this case, we should provide a Fix-It that adds ", b: Int, c: Int" to C.foo, right? class Base { class C: Base { } In this case, we should provide a Fix-It that adds ", c: Int" to C.foo, right? class Base { class C: Base { } In this case, we should provide a Fix-It that adds ", b: Int" to C.foo, right? |
Yeah, that makes sense to me, there will be one fix-it for each “near-match”. |
Comment by CaoMing (JIRA) class Base { func foo(a: Int, b: Int) {} } class C: Base { override func foo() {} // error: method does not override any method from its superclass } In this case, do we provide a Fix-It that adds "a: Int, b: Int" to C.foo? theindigamer (JIRA User) @theblixguy |
Comment by CaoMing (JIRA) @slavapestov @theblixguy Could you help to review and give me some suggestion? Thank you. |
Additional Detail from JIRA
md5: be871146c13ac26dbbf04275c83c2233
Issue Description:
For code like this following:
we should provide a Fix-It that adds ", b: Int" to C.foo.
The text was updated successfully, but these errors were encountered: