title: f# inline method chosen principal confusing
body: <pre><code>type FooBar = FooBar with 
    static member print (a:FooBar) = printfn "%s" "foobar"
  
  type PrintDefault = PrintDefault with
    static member inline print (a:int) = printfn "%s" "int"
    static member inline print (a:string) = printfn "%s" "string"
  
    static member inline print (a:obj) = printfn "%s" "object" // override others ?
  
  let inline printOrDefault (a:^a, b:^b) =
    ((^a or ^b):(static member print: ^a -&gt; unit) a)
  
  let inline print a =
    printOrDefault (a, PrintDefault)
  
  print 42
  print "hello"
  print FooBar
  print (box 42)
  </code></pre>
  
  <p>doesn't method choosing follow the narrowest principal? but here the <code>print : obj -&gt; unit</code> method override others .</p>
  
  <pre><code>public static void print&lt;a&gt;(a a)
  {
      "Dynamic invocation of print is not supported";
      throw new NotSupportedException();
  }
  </code></pre>
  
  <p>if i don't supply the <code>obj print</code>, method invoke by <code>c#</code> will get an <code>NotSupportedException</code>，if i supply the <code>obj print</code>, behavior in f# are messed up. </p>
  
  <p>what is the method choose principal here ? </p>
  
  <p>beyond c# interop, if invoke through <code>printOrDefault</code> not by <code>print</code> , things are correct.</p>
  
  <pre><code>print 42 // "object"
  print "hello" // "object"
  print FooBar // "object"
  print (box 42) // "object"
  
  printfn "----------------------------"
  
  printOrDefault (42, PrintDefault) // "int"
  printOrDefault ("hello", PrintDefault) // "string"
  printOrDefault (FooBar, PrintDefault) // "foobar"
  printOrDefault (box 42, PrintDefault) // "object"
  </code></pre>