title: Swift 2.2 Generics: "Cannot convert return expression of type ItemPageControllerFactory to return type T"
body: <p>I have an 'ItemContainer' protocol and UIViewController subclass 'ItemPageController' that conforms to the protocol.</p>
  
  <p>I also have a 'ItemContainerControllerFactory' protocol and a struct that conforms to this protocol.</p>
  
  <p>The issue: I wish to create a method that returns an appropriate ItemControllerControllerFactory sub-type. However, I get the following compiler error: <strong>"Cannot convert return expression of type ItemPageControllerFactory to return type T"</strong> </p>
  
  <pre><code>protocol ItemContainer {
      func navigateToItem(item:Item)
  }
  
  class ItemPageController : UIViewController, ItemContainer {
      func navigateToItem(item:Item) { ... }
  }
  
  protocol ItemContainerControllerFactory {
      associatedtype ContainerType : UIViewController, ItemContainer
      func itemContainerController() -&gt; ContainerType
  }
  
  struct ItemPageControllerFactory: ItemContainerControllerFactory {
      typealias ContainerType = ItemPageController
  
      func itemContainerController() -&gt; ContainerType {
          return ContainerType()
      }
  }
  
  //Goal: Be able to return different ItemContainerControllerFactory depending on some logic... (Currently hard coded to ItemPageControllerFactory)
  func itemContainerFactory&lt;T:ItemContainerControllerFactory&gt;() -&gt; T {    
      return ItemPageControllerFactory() //COMPILER ERROR: "Cannot convert return expression of type ItemPageControllerFactory to return type T"
  }
  </code></pre>
  
  <p>Any ideas of what I'm doing wrong?</p>