Swift dynamic dispatch not handling a default protocol implementation override case
Originator: | srdan.rasic | ||
Number: | rdar://23067007 | Date Originated: | 12-Oct-2015 10:23 AM |
Status: | Open | Resolved: | |
Product: | Swift | Product Version: | 2 |
Classification: | Other Bug | Reproducible: | Always |
If a subclass overrides default method implementation of a protocol that the base class conforms to, it will not be used unless base class overrides it too. Steps to Reproduce: protocol P { func foo() } extension P { func foo() { print("p foo") } } class A: P { // func foo() { // print("a foo") // } } class B: A { /* override */ func foo() { print("b foo") } } let o: P = B() o.foo() // prints: p foo Expected Results: "b foo" should be printed Actual Results: Prints "p foo". If I remove comments (have base method implement it too), it works correctly. Version: Xcode 7.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!