title: Conform class extension to generic protocol function
body: <p><strong>* Short version *</strong></p>
  
  <p><em>How can I conform a class (extension) to a generic protocol function?</em></p>
  
  <p><strong>* Long version *</strong></p>
  
  <p>This is a small part of a data structure to support a paginated collection,</p>
  
  <pre><code>protocol Pageable { 
       //an object whose can be in a collection
  }
  
  protocol Page{ //a page of a collection that can be paginated
  
      associatedtype PageItemType
  
      func itemAt&lt;PageItemType:Pageable&gt;(index: Int) -&gt; PageItemType  
  }
  
  //Bonus question
  //class PagedCollection&lt;PageType:Page, ItemType:Pageable&gt; {
      //...
  //}
  </code></pre>
  
  <p>Here is the implementation of the protocols with a "real" case:</p>
  
  <pre><code>class Person : Pageable{}
  
  class People {
      var people: [Person]?
  }
  
  //Mark: - Page
  
  extension People: Page{ /*** error 1 ***/
  
      typealias PageItemType = Person
  
      func itemAt(index: Int) -&gt; Person{
          let person : Person = self.people![index]
          return person
      }
  }
  </code></pre>
  
  <p>Obtaining the following <strong>error</strong> (1):</p>
  
  <blockquote>
    <p><em>Type 'People' does not conform to protocol 'Page'</em></p>
    
    <blockquote>
      <p>Protocol requires nested type 'PageItemType'</p>
    </blockquote>
  </blockquote>
  
  <p>I also tried making it explicit but i just got a different error: </p>
  
  <pre><code>//Mark: - Page
  
  extension People: Page{
  
      typealias PageItemType = Person
  
      func itemAt&lt;PageItemType:Pageable&gt;(index: Int) -&gt; PageItemType{
          let person : Person = self.people![index]
          return person /*** error 2 ***/
      }
  }
  </code></pre>
  
  <p>Obtaining the following <strong>error</strong> (2):</p>
  
  <blockquote>
    <p>Cannot convert return expression of type 'Person' to return type 'PageItemType'</p>
  </blockquote>
  
  <p>So: *How can i let <code>itemAt</code> function return a valid type for the PageItemType typealias? </p>
  
  <p><strong>* Bonus *</strong></p>
  
  <p><strong>Bonus question</strong> worth a 50 bounty (if answer is longer than a row i'll open a new question): 
  Referring to the first code snippet <code>PagedCollection</code></p>
  
  <ul>
  <li>given that each Page implementation has always a known implementation of Pageable protocol objet type</li>
  <li>is there a way to avoid declaring <code>ItemType:Pageable</code> ? Or at least enforce it with a <code>where</code> clause?</li>
  </ul>