Suppose the following toy example:
protocol AwesomeType: Equatable { var thingy: Int { get } } extension Array where Element: Equatable { func doThing { ... } } extension Array where Element: AwesomeType { func doThing { ... } } extension String: AwesomeType { var thingy: Int { return 42 } }
If I have an array of String - [ "Foo", "Bar", "Baz" ] - and I call doThing() on it, which implementation will be called? Why?
I believe this is determined at compile time; in other words, this is not dynamic dispatch. But how is this determined? It looks like it will be like the rules around protocol extensions, but this is a dynamic sending situation ...
source share