title: How to reference a generic class with a constraint from a Protocol with a typealias in Swift?
body: <p>I'm try to define a protocol <code>P2</code> so that it returns a generic class with a constraint on another protocol <code>P1</code>, e.g:</p>
  
  <pre><code>protocol P1 {}
  
  class C&lt;T : P1&gt; {}
  
  public protocol P2 {
      typealias T
      class func c() -&gt; C&lt;T&gt;
  }
  </code></pre>
  
  <p>But this results in the following compiler error:</p>
  
  <pre><code>error: type 'T' does not conform to protocol 'P1'
      class func c() -&gt; C&lt;T&gt;
  </code></pre>
  
  <p>There doesn't seem to be any combination that allows this, e.g. the next obvious syntax:</p>
  
  <pre><code>protocol P1 {}
  
  class C&lt;T : P1&gt; {}
  
  public protocol P2 {
      typealias T
      class func c() -&gt; C&lt;T : P1&gt;
  }
  </code></pre>
  
  <p>Errors with:</p>
  
  <pre><code>error: expected '&gt;' to complete generic argument list
      class func c() -&gt; C&lt;T : P1&gt;
                            ^
  note: to match this opening '&lt;'
      class func c() -&gt; C&lt;T : P1&gt;
  </code></pre>
  
  <p>Is this possible to do in Swift?</p>