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-8473] Broken protocol/class interaction #50994

dabrahams opened this issue Aug 6, 2018 · 0 comments

[SR-8473] Broken protocol/class interaction #50994

dabrahams opened this issue Aug 6, 2018 · 0 comments


Copy link

@dabrahams dabrahams commented Aug 6, 2018

Previous ID SR-8473
Radar None
Original Reporter @dabrahams
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 3cf7eef6af2f039969919debd16c6dd2


  • SR-103 Protocol Extension: function's implementation cannot be overridden by a subclass

Issue Description:

protocol P {
    func f() -> Int

extension P {
    func f() -> Int { return 0 }
    func g() -> Int { return f() }

class X : P {
    init() {  }

class Y : X {
    // Compiler lets me write this, and claims that Y conforms to P (see
    // "redundant conformance" error below), however...
    func f() -> Int { return 1 }

print(Y().g()) // prints 0!

class Y1 : X {
    // error: method does not override any method from its superclass
    override func f() -> Int { return 1 }

// error: redundant conformance of 'Y2' to protocol 'P'
class Y2 : X, P {
    func f() -> Int { return 1 }
@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
None yet

No branches or pull requests

1 participant