The VOS Type System, while it describes inheritance, object layout, name hiding, and overriding of virtual methods does not discuss overloading at all. While this is surprising, it arises from the fact that overloading is entirely handled by compilers that target the VOS Type System and not the type system itself. In the metadata, all references to types and type members are fully resolved and include the precise signature that is intended. This choice was made since every programming language has its own set of rules for coercing types and the VES does not provide a means for expressing those rules.
Following the rules of the VOS Type System, it is possible for names to be defined in the same scope as long as they differ in either kind (field, method, etc.) or signature. The CLS imposes a stronger restriction for overloading methods. Within a single scope, a given name may refer to any number of methods provided they differ in any of the following:
Notice that the signature includes more information but CLS-compliant languages need not produce or consume classes that differ only by that additional information:
There is one exception to this rule. For the special names op_Implicit
and op_Explicit
described in Conversion Operators methods may be provided that differ only by their return type. These are marked specially and may be ignored by compilers that don’t support operator overloading.
Note that properties may not be overloaded by type (that is, by the return type of their getter method), but indexed properties may be overloaded with different number or types of indices (that is, by the number and types of the parameters of its getter method). Otherwise, the overloading rules for properties are identical to the method overloading rules.
CLS Rule 36: Fields and events may not be overloaded within a given class.
CLS Rule 37: Properties, instance methods, and virtual methods may be overloaded based only on the types of their parameters, except the methods named op_Implicit and op_Explicit which may also be overloaded based on their return type.