protocol where clause problem


(Adel Zhang) #1

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