This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!
10.3.3 Applicable function member
Given a method and a set of positional arguments and named arguments, it is possible to determine if the method is applicable to the arguments through the following algorithm:
- First, match each positional argument in order to the list of method parameters. If there are more positional arguments than parameters and the last parameter is not a paramarray, the method is not applicable. Otherwise, each additional positional argument is matched to a pseduo-parameter of the element type of the paramarray. If a positional argument is omitted and the type of the paramarray is not
Object
, the method is not applicable.
- Next, match each named argument to a parameter with the given name. If one of the named arguments fails to match, or matches an argument already matched with another argument (positional or named), the method is not applicable.
- Finally, if there are parameters that have not been matched that are not optional, then the method is not applicable. Otherwise, the default value specified in the optional parameter declaration is matched to the parameter.
Once a set of arguments have been matched to parameters, each match must be checked for type compatibility. The following algorithm determines if an argument is compatible with a parameter:
- If the parameter is a value parameter and the value of the argument is implicitly convertible to the type of the parameter, then they are compatible.
- If the parameter is a reference parameter and the type of the argument is the same or implicitly convertible to and from the type of the parameter, then they are compatible.
- Otherwise, the argument and parameter are not compatible.