I think this looks like a compiler bug. Note that:
protocol Fooable {
func foo()
}
protocol Barable {
func bar()
}
protocol Foobarable : Fooable, Barable {
}
// Conditionally conforming Array to Foobarable works as expected:
extension Array: Foobarable where Element: Foobarable {
func foo() { forEach { $0.foo() } }
func bar() { forEach { $0.bar() } }
}
// And it also works on eg Optional:
extension Optional: Foobarable where Wrapped: Foobarable {
func foo() { self?.foo() }
func bar() { self?.bar() }
}
// But, for some reason, it doesn't work on for example this:
struct MyArrayOfOne<Element> {
let element: Element
}
extension MyArrayOfOne: Foobarable where Element: Foobarable { // <- Error
func foo() { element.foo() }
func bar() { element.bar() }
}
// Error: Type 'MyArrayOfOne<Element>' does not conform to protocol 'Barable'
Filed SR-7253