title: Why can i make same-type requirement in swift with generics? Is there any way?
body: <p>Ok so i have some class defined like this:</p>
  
  <pre><code>public final class Process&lt;InputType, OutputType, Memory&gt;
  </code></pre>
  
  <p>And i want to make the function available only for case when InputType and 
  OutputType are exactly same type.
  So i tried like this like this:</p>
  
  <pre><code>extension Process where InputType == OutputType { }
  </code></pre>
  
  <p>But this would result in:</p>
  
  <blockquote>
    <p>Same-type requirement makes generic parameters <code>InputType</code> and
    <code>OutputType</code> equivalent</p>
  </blockquote>
  
  <p>So then i've gone a bit far and tried to do it like this:</p>
  
  <pre><code>func bypass&lt;SameType&gt;() -&gt; Process&lt;SameType, SameType, Memory&gt; where OutputType == InputType {}
  </code></pre>
  
  <p>But this would result in exactly same error.
  So the question is why can't i define generics in such way that two generic types would be Equivalent, cause that's exactly what i wanted. I wanted to define function available only for this case, that would fail at compile time if this rule is not followed.</p>
  
  <p>So right now i'm using something like this:</p>
  
  <pre><code>public static func bypass&lt;SameType&gt;() -&gt; Process&lt;SameType, SameType, Memory&gt;
  </code></pre>
  
  <p>Which would ultimately fail only at runtime and not even when created but when the concrete class is triggered for action.</p>
  
  <p>Is there any way to define <code>extension</code> or <code>function</code> for generic parameters of same type that would just not compile(result in compile time error)?</p>
  
  <p>Update: some details of implementations are missed cause would make code unreadable and they are not critical for the context</p>