Skip to content
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

Open
CodaFi opened this issue Sep 9, 2021 · 2 comments
Open

[SR-15176] Fixit for override func that should be override var #57499

CodaFi opened this issue Sep 9, 2021 · 2 comments

Comments

@CodaFi
Copy link
Member

@CodaFi CodaFi commented Sep 9, 2021

Previous ID SR-15176
Radar rdar://28337871
Original Reporter @CodaFi
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, DiagnosticsQoI, StarterBug
Assignee jiaren wang (JIRA)
Priority Medium

md5: b17661d61829d04b65f822d78b07388a

Issue Description:

Consider

class C {
  var canBecomeFirstResponder: Bool

  init() {}
}

class D: C {
    override func canBecomeFirstResponder() -> Bool {
    }
}

We should add a special case to diagnoseGeneralOverrideFailure that tries to see if it can correct no-args FuncDecls to VarDecls and vice-versa.

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Sep 9, 2021

Comment by jiaren wang (JIRA)

I would like give a shot on this. Could I get some hint?

@LucianoPAlmeida
Copy link
Collaborator

@LucianoPAlmeida LucianoPAlmeida commented Sep 9, 2021

If I understand it correctly, the idea it here

diags.diagnose(decl, diag::override_multiple_decls_base,
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-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants