Given the set of methods overloaded on a name, the following algorithm determines the applicable method to an argument list:
M
and N
, if M
is "more applicable" than N
to the argument list, then eliminate N
from the set. If the set is empty or contains more than one member, an error results. If only one member remains in the set, then that is the applicable member..A member M
is considered more applicable than N
if and only if for each formal parameter Mj
and Nj
that match an actual parameter Aj
:
Mj
and Nj
have identical types, orMj
to the type Nj
.Note that because of the named parameter syntax, the ordering of the actual and formal parameters may not be the same. It is important to note that overload resolution is done on signatures, not on the original method declaration. This means that optional parameters and paramarrays play no part in the process, having already been factored into a method's signature.