title: Limit function parameter argument to base class in Swift
body: <p>Assume the following setup:</p>
  
  <pre><code>class BaseClass&lt;T&gt; { }
  
  class SubClass&lt;T&gt;: BaseClass&lt;T&gt; { }
  
  infix operator &gt;-- { associativity left }
  
  func &gt;-- &lt;T&gt;(lhs: BaseClass&lt;T&gt;, rhs: SubClass&lt;T&gt;) {
      // do something here
  }
  </code></pre>
  
  <p>What I am looking for is a way to exclude <code>SubClass</code> from being used as the <code>lhs</code> argument with the operator <code>&gt;--</code>. It would be kind of a negative type constraint on a generic argument - i.e., <code>T: BaseClass where T != Subclass</code>:</p>
  
  <pre><code>func &gt;-- &lt;T, B: BaseClass&lt;T&gt; where B != SubClass&lt;T&gt;&gt;(lhs: B, rhs: SubClass&lt;T&gt;)
  </code></pre>
  
  <p>But it does not appear that there is a <code>!=</code> argument that you can supply as a negative type constraint for a generic. Is there a way to do this?</p>
  
  <p>Thanks!</p>
  
  <p>EDIT:</p>
  
  <p>I think I can actually make the question less complicated - I think the following setup gets at exactly the same issue but without some distracting details:</p>
  
  <pre><code>class BaseClass { }
  class SubClass: BaseClass { }
  
  // This is what I want to be able to do, but don't know how
  // or if it is possible:
  func doSomething&lt;B: BaseClass where B != SubClass&gt;(arg: B) { }
  </code></pre>
  
  <p>Hope I didn't just confuse everyone more, but the "infix operator" part and the fact that <code>BaseClass</code> was a generic <code>BaseClass&lt;T&gt;</code> aren't really important to the question...</p>