[swift-users] protocol where clause problem
adelzhang at qq.com
adelzhang at qq.com
Thu Jan 12 01:25:44 CST 2017
hello all!
I'm wondering if somebody can explain following snippet to me.
protocol P {
associatedtype Element
func next() -> Element
}
protocol Q {
associatedtype T : P
func makeT() -> T
}
extension Q where Self.T == Self {
func makeT() -> Self {
return self
}
}
// Why class A conform to protocol Q successfully?
class A: Q, P {
func next() -> Int {
return 0
}
}
`class A` does not declare associated type `T` explicitly. Why where
clause check is passed ?
---
Regards
--adel
More information about the swift-users
mailing list