I find this very surprising:
protocol State {
func enterState ()
func test ()
}
extension State {
func enterState () { print ("State") }
func test () { enterState () }
}
class State0: State {
}
class State1: State0 {
func enterState () { print ("State1") }
}
let x = State1 ()
x.enterState () // prints "State1"
x.test () // prints "State"Notice that in that last line, in method 'test' an object of class State1 invokes State.enterState (), not self.enterState (). Is this intentional or a bug?
The current documentation says
"If a conforming type provides its own implementation of a required method or property, that implementation will be used instead of the one provided by the extension."
To my mind, 'State1' is a conforming type, and it does provide its own implementation of 'enterState', but that implementation isn't being used.