I need help with understanding protocols with associated types.
Why this code doesn't compile:
protocol A {
typealias AssociatedType
}
extension A where Self: MyClass {
func f(x: AssociatedType) { //'AssociatedType' is ambiguous for type lookup...
// do stuff
}
}
class MyClass: A {
typealias AssociatedType = Int
}
but it works when class is replaced with subclass
protocol A {
typealias AssociatedType
}
extension A where Self: MyClass {
func f(x: AssociatedType) {
// do stuff
}
}
class MySubclass: MyClass, A {
typealias AssociatedType = Int
}