title: Swift Equatable on a protocol
body: <p>I don't think this can be done but I'll ask anyway. I have a protocol:</p>
  <pre><code>protocol X {}
  </code></pre>
  <p>And a class:</p>
  <pre><code>class Y:X {}
  </code></pre>
  <p>In the rest of my code I refer to everything using the protocol X. In that code I would like to be able to do something like:</p>
  <pre><code>let a:X = ...
  let b:X = ...
  if a == b {...}
  </code></pre>
  <p>The problem is that if I try to implement <code>Equatable</code>:</p>
  <pre><code>protocol X: Equatable {}
  func ==(lhs:X, rhs:X) -&gt; Bool {
      if let l = lhs as? Y, let r = hrs as? Y {
          return l.something == r.something
      }
      return false
  } 
  </code></pre>
  <p>The idea to try and allow the use of <code>==</code> whilst hiding the implementations behind the protocol.</p>
  <p>Swift doesn't like this though because <code>Equatable</code> has <code>Self</code> references and it will no longer allow me to use it as a type. Only as a generic argument.</p>
  <p>So has anyone found a way to apply an operator to a protocol without the protocol becoming unusable as a type?</p>