I have a protocol with an associatedType
.
I want to give a default typealias
for that type in the protocol extension. This is to be done only for classes that inherit from a particular class.
protocol Foo: class {
associatedtype Bar
func fooFunction(bar: Bar)
}
Protocol extension:
extension Foo where Self: SomeClass {
typealias Bar = Int
func fooFunction(bar: Int) {
// Implementation
}
}
The compiler complains that 'Bar' is ambiguous for type lookup in this context
. I was unable to find anything helpful in swift book too.