title: Unexpected behavior with overloaded methods
body: <p>I'm a bit confused about groovys method overloading behavior: Given the class
  and tests below, I am pretty okay with <code>testAStringNull</code> and <code>testBStringNull</code>
  throwing ambiguous method call exceptions, but why is that not the case for
  <code>testANull</code> and <code>testBNull</code> then?</p>
  
  <p>And, much more importantly: why does <code>testBNull(null)</code>
  call <code>String foo(A arg)</code>? I guess the object doesn't know about the type of the variable it's bound to, but why is that call not ambiguous to groovy while the others are?</p>
  
  <p>(I hope I explained well enough, my head hurts from generating this minimal
  example.)</p>
  
  <pre><code>class Foo {
      static class A {}
      static class B {}
  
      String foo(A arg) { return 'a' }
  
      String foo(String s, A a) { return 'a' }
  
      String foo(B arg) { return 'b' }
  
      String foo(String s, B b) { return 'b' }
  }
  </code></pre>
  
  <p>Tests:</p>
  
  <pre><code>import org.junit.Test
  import Foo.A
  import Foo.B
  
  class FooTest {
      Foo foo = new Foo()
  
      @Test
      void testA() {
          A a = new A()
          assert foo.foo(a) == 'a'
      }
  
      @Test
      void testAString() {
          A a = new A()
          assert foo.foo('foo', a) == 'a'
      }
  
      @Test()
      void testANull() {
          A a = null
          assert foo.foo(a) == 'a'
      }
  
      @Test
      void testAStringNull() {
          A a = null
          assert foo.foo('foo', a) == 'a'
      }
  
      @Test
      void testB() {
          B b = new B()
          assert foo.foo(b) == 'b'
      }
  
      @Test
      void testBString() {
          B b = new B()
          assert foo.foo('foo', b) == 'b'
      }
  
      @Test
      void testBNull() {
          B b = null
          assert foo.foo(b) == 'b'
      }
  
      @Test
      void testBStringNull() {
          B b = null
          assert foo.foo('foo', b) == 'b'
      }
  
  }
  </code></pre>