title: Scope of a Type Name in Protocols
body: <p>I find myself hitting name space conflicts in type declarations.  Like:</p>
  
  <pre><code>protocol Identifier : Hashable {}
  
  // Something is Identifiable if it has an Identifier
  protocol Identifiable : Hashable {
    typealias Identifier : Identifier  // error: doesn't 'see' 'protocol Identifier'
    var identifier : Identifier { get }
  }
  </code></pre>
  
  <p>The simple solution is to define <code>protocol IdentifierType : Hashable {}</code> but that doesn't read right to me.  Or in <code>Identifiable</code> to use <code>typealias IdentifierType : Identifier</code> but then all types satisfying <code>Identifiable</code> specialize on <code>IdentiferType</code> and that doesn't read right to me.</p>
  
  <p>Another case:</p>
  
  <pre><code>protocol Food {}
  class FoodService &lt;Food : Food&gt; {}  // error
  </code></pre>
  
  <p>So what is the naming convention that I should be using? Am I just formulating the relationship between two types incorrectly?  Is there a way to express <code>typealias Identifier : Global.Identifier</code>?</p>
  
  <p>Edit: Responding to a Comment -- If instead I avoid the <code>typealias</code> completely and tried:</p>
  
  <pre><code>protocol Identifiable : Hashable {
    var identifier : Identifier { get }
  }
  </code></pre>
  
  <p>then I get a compiler error of "Protocol Identifier can only be used as a generic constraint ..."</p>