Dynamic call bug

protocoal Base {
 func fly()

extension Base {
 func fly() {
  print("base fly")
  func testFly() {

class Animal: Base {

class Bird: Animal {
 func fly() {
  print("Bird fly")

let t1 = Animal()
let t2 = Bird()
t1.testFly() // fly
t2.testFly() // fly
t2.fly() // Bird fly

usual, when call t2.testFly(), i want get "Bird fly"''s result. how can i do?

This is SR-103.

The workaround is to provide an implementation in the base class (here, Animal).

Terms of Service

Privacy Policy

Cookie Policy