title: Add constraints to typealiases inside Swift protocols
body: <p>How can I indicate that <code>B.Generator.Element</code> should be <code>A</code>?</p>
  
  <pre><code>protocol SomeProtocol {
      typealias A
      typealias B: CollectionType
      func f(a: A) -&gt; B
  }
  </code></pre>
  
  <p>I realise that I can do <code>func f(node: B.Generator.Element) -&gt; B</code> and eliminate <code>A</code> altogether, but I can't do this if <code>A</code> is defined in some other protocol and <code>SomeProtocol</code> inherits from it.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Added example</p>
  
  <pre><code>protocol P {
      typealias A
  }
  
  protocol Q: P {
      typealias B: CollectionType
      typealias A = B.Generator.Element
      func f(node: A) -&gt; B
  }
  
  func g&lt;A, T: Q where A == T.A&gt;(arg1: T, arg2: A) {
      let collection = arg1.f(arg2)
      collection.contains(arg2) // Error here
  }
  </code></pre>
  
  <p><strong>Edit 2:</strong>
  To clarify, I am looking to somehow specify <code>A == B.Generator.Element</code> in the protocol itself since I must use a free function. I found a <a href="https://forums.developer.apple.com/message/46217#46217" rel="nofollow">thread</a> in the developer forums with precisely my problem. Looks like its a limitation in the current type system. I've filed a radar, let's hope it gets resolved :)</p>
  
  <p><strong>Edit 3:</strong>
  A radar already exists for the issue. Use rdar://21420236 while filing.</p>