diff --git a/.github/workflows/dependencies/GrammarTestingEnv.tgz b/.github/workflows/dependencies/GrammarTestingEnv.tgz index 684ea9476..9d372d847 100644 Binary files a/.github/workflows/dependencies/GrammarTestingEnv.tgz and b/.github/workflows/dependencies/GrammarTestingEnv.tgz differ diff --git a/standard/classes.md b/standard/classes.md index ce156aa8d..9ec453396 100644 --- a/standard/classes.md +++ b/standard/classes.md @@ -2155,13 +2155,13 @@ A declaration has a valid combination of modifiers if all of the following are t Methods are classified according to what, if anything, they return: -- If `ref` is present, the method is ***returns-by-ref*** and returns a *variable reference*, that is optionally read-only; -- Otherwise, if *return_type* is `void`, the method is ***returns-no-value*** and does not return a value; -- Otherwise, the method is ***returns-by-value*** and returns a value. +- If `ref` is present, the method is ***return-by-ref*** and returns a *variable reference*, that is optionally read-only; +- Otherwise, if *return_type* is `void`, the method is ***return-no-value*** and does not return a value; +- Otherwise, the method is ***return-by-value*** and returns a value. -The *return_type* of a returns-by-value or returns-no-value method declaration specifies the type of the result, if any, returned by the method. Only a returns-no-value method may include the `partial` modifier ([§15.6.9](classes.md#1569-partial-methods)). If the declaration includes the `async` modifier then *return_type* shall be `void` or the method returns-by-value and the return type is a *task type* ([§15.14.1](classes.md#15141-general)). +The *return_type* of a return-by-value or return-no-value method declaration specifies the type of the result, if any, returned by the method. Only a return-no-value method may include the `partial` modifier ([§15.6.9](classes.md#1569-partial-methods)). If the declaration includes the `async` modifier then *return_type* shall be `void` or the method return-by-value and the return type is a *task type* ([§15.14.1](classes.md#15141-general)). -The *ref_return_type* of a returns-by-ref method declaration specifies the type of the variable referenced by the *variable_reference* returned by the method. +The *ref_return_type* of a return-by-ref method declaration specifies the type of the variable referenced by the *variable_reference* returned by the method. A generic method is a method whose declaration includes a *type_parameter_list*. This specifies the type parameters for the method. The optional *type_parameter_constraints_clause*s specify the constraints for the type parameters. @@ -2175,13 +2175,13 @@ The optional *parameter_list* specifies the parameters of the method ([§15.6.2] The *return_type* or *ref_return_type*, and each of the types referenced in the *parameter_list* of a method, shall be at least as accessible as the method itself ([§7.5.5](basic-concepts.md#755-accessibility-constraints)). -The *method_body* of a returns-by-value or returns-no-value method is either a semicolon, a block body or an expression body. A block body consists of a *block*, which specifies the statements to execute when the method is invoked. An expression body consists of `=>`, followed by a *null_conditional_invocation_expression* or *expression*, and a semicolon, and denotes a single expression to perform when the method is invoked. +The *method_body* of a return-by-value or return-no-value method is either a semicolon, a block body or an expression body. A block body consists of a *block*, which specifies the statements to execute when the method is invoked. An expression body consists of `=>`, followed by a *null_conditional_invocation_expression* or *expression*, and a semicolon, and denotes a single expression to perform when the method is invoked. For abstract and extern methods, the *method_body* consists simply of a semicolon. For partial methods the *method_body* may consist of either a semicolon, a block body or an expression body. For all other methods, the *method_body* is either a block body or an expression body. If the *method_body* consists of a semicolon, the declaration shall not include the `async` modifier. -The *ref_method_body* of a returns-by-ref method is either a semicolon, a block body or an expression body. A block body consists of a *block*, which specifies the statements to execute when the method is invoked. An expression body consists of `=>`, followed by `ref`, a *variable_reference*, and a semicolon, and denotes a single *variable_reference* to evaluate when the method is invoked. +The *ref_method_body* of a return-by-ref method is either a semicolon, a block body or an expression body. A block body consists of a *block*, which specifies the statements to execute when the method is invoked. An expression body consists of `=>`, followed by `ref`, a *variable_reference*, and a semicolon, and denotes a single *variable_reference* to evaluate when the method is invoked. For abstract and extern methods, the *ref_method_body* consists simply of a semicolon; for all other methods, the *ref_method_body* is either a block body or an expression body. @@ -3250,11 +3250,11 @@ When the effective return type of a method is `void` and the method has a block When the effective return type of a method is `void` and the method has an expression body, the expression `E` shall be a *statement_expression*, and the body is exactly equivalent to a block body of the form `{ E; }`. -For a returns-by-value method ([§15.6.1](classes.md#1561-general)), each return statement in that method’s body shall specify an expression that is implicitly convertible to the effective return type. +For a return-by-value method ([§15.6.1](classes.md#1561-general)), each return statement in that method’s body shall specify an expression that is implicitly convertible to the effective return type. -For a returns-by-ref method ([§15.6.1](classes.md#1561-general)), each return statement in that method’s body shall specify an expression whose type is that of the effective return type, and has a *ref-safe-context* of *caller-context* ([§9.7.2](variables.md#972-ref-safe-contexts)). +For a return-by-ref method ([§15.6.1](classes.md#1561-general)), each return statement in that method’s body shall specify an expression whose type is that of the effective return type, and has a *ref-safe-context* of *caller-context* ([§9.7.2](variables.md#972-ref-safe-contexts)). -For returns-by-value and returns-by-ref methods the endpoint of the method body shall not be reachable. In other words, control is not permitted to flow off the end of the method body. +For return-by-value and return-by-ref methods the endpoint of the method body shall not be reachable. In other words, control is not permitted to flow off the end of the method body. > *Example*: In the following code > diff --git a/standard/delegates.md b/standard/delegates.md index aacc8d647..ceccfa8a7 100644 --- a/standard/delegates.md +++ b/standard/delegates.md @@ -45,13 +45,13 @@ The `public`, `protected`, `internal`, and `private` modifiers control the acces The delegate’s type name is *identifier*. -As with methods ([§15.6.1](classes.md#1561-general)), if `ref` is present, the delegate returns-by-ref; otherwise, if *return_type* is `void`, the delegate returns-no-value; otherwise, the delegate returns-by-value. +As with methods ([§15.6.1](classes.md#1561-general)), if `ref` is present, the delegate return-by-ref; otherwise, if *return_type* is `void`, the delegate return-no-value; otherwise, the delegate return-by-value. The optional *parameter_list* specifies the parameters of the delegate. -The *return_type* of a returns-by-value or returns-no-value delegate declaration specifies the type of the result, if any, returned by the delegate. +The *return_type* of a return-by-value or return-no-value delegate declaration specifies the type of the result, if any, returned by the delegate. -The *ref_return_type* of a returns-by-ref delegate declaration specifies the type of the variable referenced by the *variable_reference* ([§9.5](variables.md#95-variable-references)) returned by the delegate. +The *ref_return_type* of a return-by-ref delegate declaration specifies the type of the variable referenced by the *variable_reference* ([§9.5](variables.md#95-variable-references)) returned by the delegate. The optional *variant_type_parameter_list* ([§19.2.3](interfaces.md#1923-variant-type-parameter-lists)) specifies the type parameters to the delegate itself. @@ -83,7 +83,7 @@ The only way to declare a delegate type is via a *delegate_declaration*. Every d ## 21.3 Delegate members -Every delegate type inherits members from the `Delegate` class as described in [§15.3.4](classes.md#1534-inheritance). In addition, every delegate type shall provide a non-generic `Invoke` method whose parameter list matches the *parameter_list* in the delegate declaration, whose return type matches the *return_type* or *ref_return_type* in the delegate declaration, and for returns-by-ref delegates whose *ref_kind* matches that in the delegate declaration. The `Invoke` method shall be at least as accessible as the containing delegate type. Calling the `Invoke` method on a delegate type is semantically equivalent to using the delegate invocation syntax ([§21.6](delegates.md#216-delegate-invocation)) . +Every delegate type inherits members from the `Delegate` class as described in [§15.3.4](classes.md#1534-inheritance). In addition, every delegate type shall provide a non-generic `Invoke` method whose parameter list matches the *parameter_list* in the delegate declaration, whose return type matches the *return_type* or *ref_return_type* in the delegate declaration, and for return-by-ref delegates whose *ref_kind* matches that in the delegate declaration. The `Invoke` method shall be at least as accessible as the containing delegate type. Calling the `Invoke` method on a delegate type is semantically equivalent to using the delegate invocation syntax ([§21.6](delegates.md#216-delegate-invocation)) . Implementations may define additional members in the delegate type. @@ -97,9 +97,9 @@ A method or delegate type `M` is ***compatible*** with a delegate type `D` if al - For each value parameter, an identity conversion ([§10.2.2](conversions.md#1022-identity-conversion)) or implicit reference conversion ([§10.2.8](conversions.md#1028-implicit-reference-conversions)) exists from the parameter type in `D` to the corresponding parameter type in `M`. - For each by-reference parameter, the parameter type in `D` is the same as the parameter type in `M`. - One of the following is true: - - `D` and `M` are both *returns-no-value*. - - `D` and `M` are returns-by-value ([§15.6.1](classes.md#1561-general), [§21.2](delegates.md#212-delegate-declarations)), and an identity or implicit reference conversion exists from the return type of `M` to the return type of `D`. - - `D` and `M` are both returns-by-ref, an identity conversion exists between the return type of `M` and the return type of `D`, and both have the same *ref_kind*. + - `D` and `M` are both *return-no-value*. + - `D` and `M` are return-by-value ([§15.6.1](classes.md#1561-general), [§21.2](delegates.md#212-delegate-declarations)), and an identity or implicit reference conversion exists from the return type of `M` to the return type of `D`. + - `D` and `M` are both return-by-ref, an identity conversion exists between the return type of `M` and the return type of `D`, and both have the same *ref_kind*. This definition of compatibility allows covariance in return type and contravariance in parameter types. diff --git a/standard/expressions.md b/standard/expressions.md index 3da7b653d..969320115 100644 --- a/standard/expressions.md +++ b/standard/expressions.md @@ -1974,9 +1974,9 @@ The optional *argument_list* ([§12.6.2](expressions.md#1262-argument-lists)) pr The result of evaluating an *invocation_expression* is classified as follows: -- If the *invocation_expression* invokes a returns-no-value method ([§15.6.1](classes.md#1561-general)) or a returns-no-value delegate, the result is nothing. An expression that is classified as nothing is permitted only in the context of a *statement_expression* ([§13.7](statements.md#137-expression-statements)) or as the body of a *lambda_expression* ([§12.21](expressions.md#1221-anonymous-function-expressions)). Otherwise, a binding-time error occurs. -- Otherwise, if the *invocation_expression* invokes a returns-by-ref method ([§15.6.1](classes.md#1561-general)) or a returns-by-ref delegate, the result is a variable with an associated type of the return type of the method or delegate. If the invocation is of an instance method, and the receiver is of a class type `T`, the associated type is picked from the first declaration or override of the method found when starting with `T` and searching through its base classes. -- Otherwise, the *invocation_expression* invokes a returns-by-value method ([§15.6.1](classes.md#1561-general)) or returns-by-value delegate, and the result is a value, with an associated type of the return type of the method or delegate. If the invocation is of an instance method, and the receiver is of a class type `T`, the associated type is picked from the first declaration or override of the method found when starting with `T` and searching through its base classes. +- If the *invocation_expression* invokes a return-no-value method ([§15.6.1](classes.md#1561-general)) or a return-no-value delegate, the result is nothing. An expression that is classified as nothing is permitted only in the context of a *statement_expression* ([§13.7](statements.md#137-expression-statements)) or as the body of a *lambda_expression* ([§12.21](expressions.md#1221-anonymous-function-expressions)). Otherwise, a binding-time error occurs. +- Otherwise, if the *invocation_expression* invokes a return-by-ref method ([§15.6.1](classes.md#1561-general)) or a return-by-ref delegate, the result is a variable with an associated type of the return type of the method or delegate. If the invocation is of an instance method, and the receiver is of a class type `T`, the associated type is picked from the first declaration or override of the method found when starting with `T` and searching through its base classes. +- Otherwise, the *invocation_expression* invokes a return-by-value method ([§15.6.1](classes.md#1561-general)) or return-by-value delegate, and the result is a value, with an associated type of the return type of the method or delegate. If the invocation is of an instance method, and the receiver is of a class type `T`, the associated type is picked from the first declaration or override of the method found when starting with `T` and searching through its base classes. #### 12.8.10.2 Method invocations diff --git a/standard/statements.md b/standard/statements.md index 083d0b7cc..396f2a0cb 100644 --- a/standard/statements.md +++ b/standard/statements.md @@ -1717,17 +1717,17 @@ return_statement A *return_statement* without *expression* is called a ***return-no-value***; one containing `ref` *expression* is called a ***return-by-ref***; and one containing only *expression* is called a ***return-by-value***. -It is a compile-time error to use a return-no-value from a method declared as being returns-by-value or returns-by-ref ([§15.6.1](classes.md#1561-general)). +It is a compile-time error to use a return-no-value from a method declared as being return-by-value or return-by-ref ([§15.6.1](classes.md#1561-general)). -It is a compile-time error to use a return-by-ref from a method declared as being returns-no-value or returns-by-value. +It is a compile-time error to use a return-by-ref from a method declared as being return-no-value or return-by-value. -It is a compile-time error to use a return-by-value from a method declared as being returns-no-value or returns-by-ref. +It is a compile-time error to use a return-by-value from a method declared as being return-no-value or return-by-ref. It is a compile-time error to use a return-by-ref if *expression* is not a *variable_reference* or is a reference to a variable whose ref-safe-context is not caller-context ([§9.7.2](variables.md#972-ref-safe-contexts)). It is a compile-time error to use a return-by-ref from a method declared with the *method_modifier* `async`. -A function member is said to ***compute a value*** if it is a method with a returns-by-value method ([§15.6.11](classes.md#15611-method-body)), a returns-by-value get accessor of a property or indexer, or a user-defined operator. Function members that are returns-no-value do not compute a value and are methods with the effective return type `void`, set accessors of properties and indexers, add and remove accessors of events, instance constructors, static constructors and finalizers. Function members that are returns-by-ref do not compute a value. +A function member is said to ***compute a value*** if it is a method with a return-by-value method ([§15.6.11](classes.md#15611-method-body)), a return-by-value get accessor of a property or indexer, or a user-defined operator. Function members that are return-no-value do not compute a value and are methods with the effective return type `void`, set accessors of properties and indexers, add and remove accessors of events, instance constructors, static constructors and finalizers. Function members that are return-by-ref do not compute a value. For a return-by-value, an implicit conversion ([§10.2](conversions.md#102-implicit-conversions)) shall exist from the type of *expression* to the effective return type ([§15.6.11](classes.md#15611-method-body)) of the containing function member. For a return-by-ref, an identity conversion ([§10.2.2](conversions.md#1022-identity-conversion)) shall exist between the type of *expression* and the effective return type of the containing function member. diff --git a/standard/variables.md b/standard/variables.md index afefc2726..922257a02 100644 --- a/standard/variables.md +++ b/standard/variables.md @@ -1044,7 +1044,7 @@ A reference variable stores a *variable_reference* ([§9.5](variables.md#95-vari > > *end example* -A ***reference return*** is the *variable_reference* returned from a returns-by-ref method ([§15.6.1](classes.md#1561-general)). This *variable_reference* is the referent of the reference return. +A ***reference return*** is the *variable_reference* returned from a return-by-ref method ([§15.6.1](classes.md#1561-general)). This *variable_reference* is the referent of the reference return. > *Example:* The following example demonstrates a reference return whose referent is an element of an array field: >