Are there statically typed inheritance programming languages ​​where method parameters are contravariant?

Theoretically, sound overrides the parent's methods in a subclass of the method, where the parameters are supertypes of parameters in the parent class, for example:

class T
  def foo(s: String) = ...

class S
  override def foo(a: Any) = ...

What programming languages ​​support this “function” and how do they solve problems such as the possibility that one subclass method can override several methods of the parent class:

class T
  def foo(s: String) = ...
  def foo(i: Int)    = ...

class S
  override def foo(a: Any) = ...

(Assuming that Stringand Intsubtypes Any.)

+5
source share
2 answers

( ) OCaml, : " , ".

( " , ..." ), Gordian , . ( , , ).

+2

, , . , , , , . . , overriding "" . , , , , , , , # 4.0 :

( http://blogs.msdn.com/b/csharpfaq/archive/2010/02/16/covariance-and-contravariance-faq.aspx)

? # 4.0. , , . , , , () (). .

0

All Articles