Skip to content

Commit 77624af

Browse files
committed
Parameter scope variance + UnscopedRef xref
| File | Change | |------|--------| | variables.md (new §parameter-scope-variance) | Overrides/implementations/delegate conversions may: add scoped to ref/in, add scoped to ref struct param, remove UnscopedRef from out/ref-of-ref-struct. Other differences = mismatch. No effect on hiding; overloads shall not differ only on scoped/UnscopedRef. | | attributes.md §UnscopedRefAttribute | Add "(§scoped-modifier)" xref to opening paragraph. |
1 parent 80e946f commit 77624af

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

standard/attributes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ Specifies that a nullable argument will not be `null` when the method returns th
12261226
12271227
### §UnscopedRefAttribute The UnscopedRef attribute
12281228
1229-
There are several cases in which a ref is treated as being implicitly scoped; that is, the ref is not allowed to escape a method. For example:
1229+
There are several cases in which a ref is treated as being implicitly scopedscoped-modifier); that is, the ref is not allowed to escape a method. For example:
12301230
12311231
- `this` for struct instance methods.
12321232
- ref parameters that refer to ref struct types.

standard/variables.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,3 +1472,18 @@ Consider the following declarations and their safe contexts:
14721472
| `scoped ref Span<int> s` | *function-member* | *caller-context* |
14731473
14741474
In this relationship the *ref-safe-context* of a value can never be wider than the *safe-context*.
1475+
1476+
### §parameter-scope-variance Parameter scope variance
1477+
1478+
The `scoped` modifierscoped-modifier) and `[UnscopedRef]` attributeUnscopedRefAttribute) on parameters affect overriding, interface implementation, and `delegate` conversion. The signature for an override, interface implementation, or `delegate` conversion may:
1479+
1480+
- Add `scoped` to a `ref` or `in` parameter.
1481+
- Add `scoped` to a parameter of a `ref struct` type.
1482+
- Remove `[UnscopedRef]` from an `out` parameter.
1483+
- Remove `[UnscopedRef]` from a `ref` parameter of a `ref struct` type.
1484+
1485+
Any other difference with respect to `scoped` or `[UnscopedRef]` between the base and the overriding, implementing, or converting signature is a mismatch.
1486+
1487+
The `scoped` modifier and `[UnscopedRef]` attribute do not affect hiding.
1488+
1489+
Overloads shall not differ only on `scoped` or `[UnscopedRef]`.

0 commit comments

Comments
 (0)