title: C# Type system support to express types that matches constraints
body: <p>The problem:</p>
  <pre><code>public class Test
  {
      public void A&lt;T&gt;(T arg)
      {
          // We have proof it's safe to call B
          if (arg is IEquatable&lt;T&gt;)
          {
              // To call B, something like this needed.
              // var arg1 = (T:IEquatable&lt;T&gt;) arg;
              // B(arg1)
  
              B(arg); // Error CS0314: The type 'T' cannot be used as type parameter 'T' in the generic type or method 'Test.B&lt;T&gt;(T)'.
                      // There is no boxing conversion or type parameter conversion from 'T' to 'System.IEquatable&lt;T&gt;'.
          }
          else
          {
              C(arg);
          }
      }
  
      public void B&lt;T&gt;(T arg)
          where T: IEquatable&lt;T&gt;
      {
          // We don't want to loos the original type T that has been passed to A&lt;T&gt;
          Console.WriteLine(typeof(T).Name);
      }
  
      public void C&lt;T&gt;(T arg)
      {
      }
  }
  </code></pre>
  <p>Do we have any C# language constructs that allows to call more generic method with more restrictions on type, if we have proofs it's safe (Higher Kinder Polymorphism, advanced pattern matching, etc) ?</p>
  <p>Do we have any option to make a weird unsafe hack to make unallowed generic method call ?
  Looks like we can express the call on IL level (Fody + <a href="https://github.com/ltrzesniewski/InlineIL.Fody" rel="nofollow noreferrer">https://github.com/ltrzesniewski/InlineIL.Fody</a>) or somehow Function Pointers can be used.
  (Sure reflection can help, but it's expensive and might cause an issues with the CoreRT native compilation).</p>