title: Swift protocol with associated type - type may not reference itself as a requirement
body: <p>I have the following protocol and its extension</p>
  
  <pre><code>public protocol RESEndpointReachable: CustomDebugStringConvertible
  {
      associatedtype EndpointType: RESEndpointReachable
  
  
      //  MARK: - Properties
  
      /// The name of the endpoint as defined in the REST URI.
      var name: String { get }
  
      /// An array of possible next endpoints that this endpoint can reach. E.g account's next endpoints would be authenticate and unauthenticate.
      var nextPossibleEndpoints: [EndpointType] { get }
  
  
      //  MARK: - Ability
  
      /// Used to process the endpoint.
      func processRequest(request: RERequest)
  
      /// Processes the next endpoint that matches the name `name`. Expects an endpoint with the name `name` to exist in `nextPossibleEndpoints`.
      func processNextEndpointWithName(name: String, request: RERequest)
  }
  
  public extension RESEndpointReachable
  {
      //  MARK: - CustomDebugStringConvertible
  
      public var debugDescription: String {
          return name
      }
  
  
      //  MARK: - RESEndpointReachable
  
      var nextPossibleEndpoints: [EndpointType] {
          return []
      }
  
      public func processRequest(request: RERequest)
      {
          //  Check all possible endpoints are being processed
          if let nextEndpoint = nextPossibleEndpoints.first
          {
              fatalError("Unhandled endpoint \(nextEndpoint).")
          }
      }
  
      public func processNextEndpointWithName(name: String, request: RERequest)
      {
          //  Get the next endpoint that matches the specified name
          let nextEndpoints = nextPossibleEndpoints.filter { $0.name == name }
  
          if nextEndpoints.count &gt; 1
          {
              fatalError("Multiple next endpoints found with the name '\(name)'.")
          }
  
          guard let nextEndpoint = nextEndpoints.first else
          {
              fatalError("No next endpoint with the name '\(name)'.")
          }
  
  
          //  Process the next endpoint
          nextEndpoint.processRequest(request)
      }
  }
  </code></pre>
  
  <p>On building, the line <code>associatedtype EndpointType: RESEndpointReachable</code> has the following error: <code>Type may not reference itself as a requirement</code>. But as I understand it this is how you use associated types in Swift.</p>
  
  <p>As you may have guessed, I always want whatever <code>EndpointType</code> ends up being set as to be a type that inherits from <code>RESEndpointReachable</code>.</p>