Skip to content

Commit 79b5563

Browse files
RexJaeschkeBillWagner
authored andcommitted
Add ref readonly parameters feature
1 parent c1146a9 commit 79b5563

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

standard/basic-concepts.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -732,21 +732,22 @@ Signatures are the enabling mechanism for ***overloading*** of members in classe
732732
- Overloading of indexers permits a class, struct, or interface to declare multiple indexers, provided their signatures are unique within that class, struct, or interface.
733733
- Overloading of operators permits a class or struct to declare multiple operators with the same name, provided their signatures are unique within that class or struct.
734734
735-
Although `in`, `out`, and `ref` parameter modifiers are considered part of a signature, members declared in a single type cannot differ in signature solely by `in`, `out`, and `ref`. A compile-time error occurs if two members are declared in the same type with signatures that would be the same if all parameters in both methods with `out` or `in` modifiers were changed to `ref` modifiers. For other purposes of signature matching (e.g., hiding or overriding), `in`, `out`, and `ref` are considered part of the signature and do not match each other.
735+
Although *parameter_mode_modifier*s are considered part of a signature, members declared in a single type cannot differ in signature solely by those modifiers. A compile-time error occurs if two members are declared in the same type with signatures that would be the same if all parameters in both methods with `out` or `in` modifiers were changed to `ref` modifiers. For other purposes of signature matching (e.g., hiding or overriding), *parameter_mode_modifier*s are considered part of the signature and do not match each other.
736736
737-
> *Note*: This restriction is to allow Cprograms to be easily translated to run on a platform that does not provide a way to define methods that differ solely in `in`, `out`, and `ref`. *end note*
737+
> *Note*: This restriction is to allow Cprograms to be easily translated to run on a platform that does not provide a way to define methods that differ solely in their *parameter_mode_modifier*s. *end note*
738738
739739
The types `object` and `dynamic` are not distinguished when comparing signatures. Therefore members declared in a single type whose signatures differ only by replacing `object` with `dynamic` are not allowed.
740740
741741
> *Example*: The following example shows a set of overloaded method declarations along with their signatures.
742742
>
743-
> <!-- Example: {template:"standalone-lib-without-using", name:"SignatureOverloading", expectedErrors:["CS0663","CS0111","CS0111","CS0111","CS0111"]} -->
743+
> <!-- Example: {template:"standalone-lib-without-using", name:"SignatureOverloading", expectedErrors:["CS0663","CS0663","CS0111","CS0111","CS0111","CS0111"]} -->
744744
> ```csharp
745745
> interface ITest
746746
> {
747747
> void F(); // F()
748748
> void F(int x); // F(int)
749749
> void F(ref int x); // F(ref int)
750+
> void F(ref readonly int x); // F(ref int) error
750751
> void F(out int x); // F(out int) error
751752
> void F(object o); // F(object)
752753
> void F(dynamic d); // error.
@@ -762,7 +763,7 @@ The types `object` and `dynamic` are not distinguished when comparing signatures
762763
> }
763764
> ```
764765
>
765-
> Note that any `in`, `out`, and `ref` parameter modifiers ([§15.6.2](classes.md#1562-method-parameters)) are part of a signature. Thus, `F(int)`, `F(in int)`, `F(out int)` , and `F(ref int)` are all unique signatures. However, `F(in int)`, `F(out int)` , and `F(ref int)` cannot be declared within the same interface because their signatures differ solely by `in`, `out`, and `ref`. Also, note that the return type and the `params` modifier are not part of a signature, so it is not possible to overload solely based on return type or on the inclusion or exclusion of the `params` modifier. As such, the declarations of the methods `F(int)` and `F(params string[])` identified above, result in a compile-time error. *end example*
766+
> Note that any *parameter_mode_modifier*s ([§15.6.2](classes.md#1562-method-parameters)) are part of a signature. Thus, `F(int)`, `F(in int)`, `F(out int)` , `F(ref int)`, and `F(ref readonly int)` are all unique signatures. However, `F(in int)`, `F(out int)`, `F(ref int)`, and `F(ref readonly int)` cannot be declared within the same interface because their signatures differ solely by their *parameter_mode_modifier*s. Also, note that the return type and the `params` modifier are not part of a signature, so it is not possible to overload solely based on return type or on the inclusion or exclusion of the `params` modifier. As such, the declarations of the methods `F(int)` and `F(params string[])` identified above, result in a compile-time error. *end example*
766767
767768
## 7.7 Scopes
768769

0 commit comments

Comments
 (0)