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-13496] Derived protocol that updates an override with a different Optional variant isn't properly handled #55938

Open
swift-ci opened this issue Sep 4, 2020 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Sep 4, 2020

Previous ID SR-13496
Radar None
Original Reporter CTMacUser (JIRA User)
Type Bug
Environment

MacBook Air (13-inch, Early 2014)

macOS Big Sur 11.0 beta (20A5354i), on external boot drive

Xcode 12.0 beta 6 (12A8189n)

Using a playground that's part of a workspace.

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: fa188c49fcdf416ec250cc4b2fde23bd

Issue Description:

Let's start with a couple of sample protocols:

protocol Clonable {
func copy(toDepth depth: Int) -> Self?
}
protocol StronglyClonable: Clonable {
func copy(toDepth depth: Int) -> Self!
}

And create two sample classes in the form of:

class SampleX { init() {} }

When I make one class conform to {Clonable} and the second to {StronglyClonable}, I get the following suggested stubs (I filled in some sample implementations.):

class Sample1: Clonable {
func copy(toDepth depth: Int) -> Self? {
return Sample1() as? Self
}
init() {}
}

class Sample2: StronglyClonable {
func copy(toDepth depth: Int) -> Self! {
return (Sample2() as! Self)
}
func copy(toDepth depth: Int) -> Self? {
return Sample2() as? Self
}
init() {}
}

In the second class, the derived protocol's update to the method is treated as a new method, not one that overrides the method from its base protocol. Further, the playground suggests both versions of the method. Then the playground also flags the second occurrence as an invalid redeclaration. I don't know which parts of this paragraph are the bug.

@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
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

1 participant