[SR-13496] Derived protocol that updates an override with a different Optional variant isn't properly handled #55938
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
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
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.
The text was updated successfully, but these errors were encountered: