Skip to content

Commit ca3742e

Browse files
committed
Apply delta from PR #1452 (Init Accessors) - 3 new review commits
1 parent 79feb67 commit ca3742e

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

standard/classes.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3570,7 +3570,7 @@ The body of a get accessor for a ref-valued property shall conform to the rules
35703570
35713571
A set accessor corresponds to a method with a single value parameter of the property type and a `void` return type. The implicit parameter of a set accessor is always named `value`. When a property is referenced as the target of an assignment ([§12.24](expressions.md#1224-assignment-operators)), or as the operand of `++` or `–-` ([§12.8.16](expressions.md#12816-postfix-increment-and-decrement-operators), [§12.9.7](expressions.md#1297-prefix-increment-and-decrement-operators)), the set accessor is invoked with an argument that provides the new value ([§12.24.2](expressions.md#12242-simple-assignment)). The body of a set accessor shall conform to the rules for `void` methods described in15.6.11](classes.md#15611-method-body). In particular, return statements in the set accessor body are not permitted to specify an expression. Since a set accessor implicitly has a parameter named `value`, it is a compile-time error for a local variable or constant declaration in a set accessor to have that name.
35723572
3573-
An init accessor corresponds to a method with a single value parameter of the property type and a `void` return type. The implicit parameter of an init accessor is always named `value`. Only during the construction phase of an object ([§15.7.3.3](classes.md#15733-init-accessors)), and if an init accessor exists, when a property is referenced as the target of an assignment ([§12.22](expressions.md#1222-anonymous-function-expressions)), or as the operand of `++` or `–-` ([§12.8.16](expressions.md#12816-postfix-increment-and-decrement-operators), [§12.9.7](expressions.md#1297-prefix-increment-and-decrement-operators)), the init accessor is invoked with an argument that provides the new value ([§12.24.2](expressions.md#12242-simple-assignment)). The body of an init accessor shall conform to the rules for `void` methods described in [§15.6.11](classes.md#15611-method-body). In particular, return statements in the init accessor body are not permitted to specify an expression. Since an init accessor implicitly has a parameter named `value`, it is a compile-time error for a local variable or constant declaration in an init accessor to have that name.
3573+
An init accessor corresponds to a method with a single value parameter of the property type and a `void` return type. The implicit parameter of an init accessor is always named `value`. Only during the construction phase of an object ([§15.7.3.3](classes.md#15733-init-accessors)), and if an init accessor exists, when a property is referenced as the target of an assignment ([§12.24](expressions.md#1224-assignment-operators)), or as the operand of `++` or `–-` ([§12.8.16](expressions.md#12816-postfix-increment-and-decrement-operators), [§12.9.7](expressions.md#1297-prefix-increment-and-decrement-operators)), the init accessor is invoked with an argument that provides the new value ([§12.24.2](expressions.md#12242-simple-assignment)). The body of an init accessor shall conform to the rules for `void` methods described in [§15.6.11](classes.md#15611-method-body). In particular, return statements in the init accessor body are not permitted to specify an expression. Since an init accessor implicitly has a parameter named `value`, it is a compile-time error for a local variable or constant declaration in an init accessor to have that name.
35743574
35753575
It is a compile-time error for a *property_declaration* containing an *init_accessor_declaration* to also have the *property_modifier* `static`.
35763576
@@ -3861,6 +3861,7 @@ An instance property containing an *init_accessor_declaration* is considered set
38613861
38623862
- During execution of an *object_initializer* ([§12.8.17.3](expressions.md#128173-object-initializers))
38633863
- During evaluation of a *with_expression*s *member_initializer_list* ([§12.10](expressions.md#1210-with-expressions))
3864+
38643865
- Inside an instance constructor of the containing or derived type, on `this` or `base`
38653866
- Inside the *init_accessor_declaration* of any property, on `this` or `base`
38663867
- Inside attribute usages with named parameters ([§23.2.3](attributes.md#2323-positional-and-named-parameters))
@@ -4160,8 +4161,8 @@ The presence of an *accessor_modifier* never affects member lookup ([§12.5](exp
41604161
Once a particular non-ref-valued property or non-ref-valued indexer has been selected, the accessibility domains of the specific accessors involved are used to determine if that usage is valid:
41614162
41624163
- If the usage is as a value ([§12.2.2](expressions.md#1222-values-of-expressions)), the get accessor shall exist and be accessible.
4163-
- If the usage is as the target of a simple assignment ([§12.24.2](expressions.md#12242-simple-assignment)), either the set or init accessor shall exist and be accessible.
4164-
- If the usage is as the target of compound assignment ([§12.24.5](expressions.md#12245-compound-assignment)), or as the target of the `++` or `--` operators ([§12.8.16](expressions.md#12816-postfix-increment-and-decrement-operators), [§12.9.7](expressions.md#1297-prefix-increment-and-decrement-operators)), both the get accessors and either the set or init accessor shall exist and be accessible.
4164+
- If the usage is as the target of a simple assignment ([§12.24.2](expressions.md#12242-simple-assignment)), the set or init accessor shall exist and be accessible.
4165+
- If the usage is as the target of compound assignment ([§12.24.5](expressions.md#12245-compound-assignment)), or as the target of the `++` or `--` operators ([§12.8.16](expressions.md#12816-postfix-increment-and-decrement-operators), [§12.9.7](expressions.md#1297-prefix-increment-and-decrement-operators)), both the get accessors and the set or init accessor shall exist and be accessible.
41654166
41664167
> *Example*: In the following example, the property `A.Text` is hidden by the property `B.Text`, even in contexts where only the set accessor is called. In contrast, the property `B.Count` is not accessible to class `M`, so the accessible property `A.Count` is used instead.
41674168
>

0 commit comments

Comments
 (0)