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-10292] Missing fix-it to add 'override' keyword while trying to override a computed property #52692

Closed
xedin opened this issue Apr 3, 2019 · 12 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers

Comments

@xedin
Copy link
Member

xedin commented Apr 3, 2019

Previous ID SR-10292
Radar rdar://problem/27800711
Original Reporter @xedin
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, StarterBug
Assignee phillfarrugia (JIRA)
Priority Medium

md5: a03a0256ed9c83cbf6af3e89d6e9a471

Issue Description:

Consider following example:

class A {
  var a: Int {
    return 42
  }

  func b() -> Int { return 42 }
}

class B: A {
  var a: Int { return 0 }

  func b() -> Int {
    return 0
  }
}

It produces following errors:

error: overriding declaration requires an 'override' keyword
    var a: Int { return 0 }
        ^
note: overridden declaration is here
    var a: Int {
        ^
error: overriding declaration requires an 'override' keyword
    func b() -> Int {
   ^
    override
note: overridden declaration is here
    func b() -> Int { return 42 }
         ^

But as you can see there is only one 'override' fix-it suggested - for `func b`.

@micahbenn
Copy link
Contributor

Can I take a shot at this? I've been wanting to contribute to Swift!

@xedin
Copy link
Member Author

xedin commented Apr 25, 2019

I believe slazarus (JIRA User) wanted to take this, but if he doesn't mind, I'm okay with that as well.

@theblixguy
Copy link
Collaborator

I actually have a PR for this (noticed a FIXME for rdar://16320042 a while ago in `checkSingleOverride()`), just haven't created it yet. I can do that now if it's ok?

@swift-ci
Copy link
Collaborator

Comment by Sam Lazarus (JIRA)

@micahbenn It looks like @theblixguy already had some work done on this, but feel free to look at the tickets labeled starter bug. There are lots of other things you can work on to get started contributing 🙂

@theblixguy
Copy link
Collaborator

I don’t mind letting @micahbenn taking over this... I can help if you get stuck!

@micahbenn
Copy link
Contributor

Appreciate it guys. And thanks @theblixguy! I'll give it a go.

@theblixguy
Copy link
Collaborator

No problem. Just a hint - the fix needs to go inside a method called `checkSingleOverride()` in TypeCheckDeclOverride.cpp. Take a look at https://github.com/apple/swift/blob/d24bc387973bcf60f5596ff387b996c1eb356456/lib/Sema/TypeCheckDeclOverride.cpp#L1633. As you can see, there's already a FIXME about this exact bug. So this is where the new code is going to go.

@micahbenn
Copy link
Contributor

@theblixguy Just an update: I've been trying to get Swift to build with Ninja so I can test my changes, but ran into some snags. I'm looking into it. https://forums.swift.org/t/unable-to-build-swift-on-mac-using-ninja/24131

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 8, 2019

Comment by Phill Farrugia (JIRA)

I've implemented a fix for this as my first starter task, if it's alright for me to submit a PR for it @micahbenn?

@micahbenn
Copy link
Contributor

Yeah, I'm fine with that. Don't know if @theblixguy had any plans if I couldn't do it. I'm still having trouble with Ninja. phillfarrugia (JIRA User)

@theblixguy
Copy link
Collaborator

Feel free to put the PR up. I’ll take a look!

@swift-ci
Copy link
Collaborator

Comment by Phill Farrugia (JIRA)

Fix has been merged into master https://github.com/apple/swift/pull/25315/files

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants