[swift-evolution] [Proposal draft] Conditional conformances

Douglas Gregor dgregor at apple.com
Wed Sep 28 11:30:30 CDT 2016


> On Sep 28, 2016, at 2:55 AM, Anton Zhilin <antonyzhilin at gmail.com> wrote:
> 
> I find the limitation of non-intersection of conditional conformance reqirements quite limiting. Can it be lifted in case there are no overloaded functions between extensions?
> 
> protocol A { func foo() }
> protocol B { func bar() }
> 
> extension Array: A where Element: A {
>     func foo() { return self.first!.foo() }
> }
> extension Array: B where Element: B {
>     func bar() { return self.first!.bar() }
> }
> 
> let arr: Array<T>
> arr.foo()
> 
> What is ambiguous here?

Nothing. These conformances are not overlapping, because A and B are independent protocols. The first extension declares a conditional conformance to A, the second declares a conditional conformance to B.

	- Doug



More information about the swift-evolution mailing list