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-118] Protocol extensions cannot be overridden in subclasses #42740

Closed
swift-ci opened this issue Dec 7, 2015 · 3 comments
Closed

[SR-118] Protocol extensions cannot be overridden in subclasses #42740

swift-ci opened this issue Dec 7, 2015 · 3 comments
Labels

Comments

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Dec 7, 2015

Previous ID SR-118
Radar None
Original Reporter TomasLinhart (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: 4d6afae532aeb854969ea8b9cc15c2b1

duplicates:

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

is duplicated by:

  • SR-1271 Protocol extension method being called over subclass implementation.

relates to:

  • SR-302 Ambiguous Behavior of Protocols with Default Implementations

Issue Description:

If there is a protocol with a protocol extension then if the protocol extension implementation is overridden in subclass, it will be not used.

You can check following code that is demonstrating the problem.

protocol Valuable {
    var uppercaseValue: String { get }
    var value: String { get }
}

extension Valuable {
    var uppercaseValue: String {
        return value.uppercaseString
    }
    
    var value: String {
        return "default"
    }
}

class A: Valuable {}

class B: A {
    var value: String {
        return "b"
    }
}


print(B().value) // This is correctly b.
print(B().uppercaseValue) // This is DEFAULT
@swift-ci
Copy link
Collaborator Author

@swift-ci swift-ci commented Apr 20, 2016

Comment by Dale Buckley (JIRA)

This is still not fixed as of Swift 2.2.

@swift-ci
Copy link
Collaborator Author

@swift-ci swift-ci commented Apr 20, 2016

Comment by Dale Buckley (JIRA)

I am reopening this issue as it has yet to be fixed in Swift 2.2 and I can't find any trace of the fix.

@belkadan
Copy link
Contributor

@belkadan belkadan commented Apr 20, 2016

It's not fixed; it's just already tracked by SR-103, which remains open.

@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
Projects
None yet
Development

No branches or pull requests

2 participants