title: Is there a language allowing dynamic binding for arguments?
body: <p>Is there a language allowing a supertype A defining a method useFoo (Foo foo) such as B, derivated from A defining a method useFoo(Bar bar), (Bar is derivated from Foo), when using B as a A with a Foo that is a Bar, it will run the most specialised version of useFoo ?</p>
  
  <p>Java example (not working, unfortunately) :</p>
  
  <pre><code>public class Foo {
  
  }
  
  public class Bar extends Foo {
  
  }
  
  
  public class A {
      void useFoo (Foo foo) {
          System.out.println("A");
      }
  }
  
  public class B extends A {
      void useFoo (Bar bar) {
          System.out.println("B");
      }
  }
  
  public static void main(String[] args) {
      A b = new B();
      b.useFoo(new Bar()); // actually returns "A", is there one returning "B" ?
  }
  </code></pre>
  
  <p>I know there is a way to make this happen with a "few" lines (using a visitor for instance) but I would like to know if any (compiled) language would allow it.</p>
  
  <p>I admit I would like to know if this is even possible, the contrary would not surprise me, and what prevents it ?</p>
  
  <p>Is there a better name for this concept ?</p>
  
  <p>Edit : In java, it is named Contravariance. thank you @Kevinrob</p>