Skip to content

Commit 36b3b28

Browse files
RexJaeschkeBillWagner
authored andcommitted
support record with sealed ToString
1 parent 19d0bb3 commit 36b3b28

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

standard/classes.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6282,7 +6282,9 @@ The record class shall include a synthesized method equivalent to a method decla
62826282
public override string ToString();
62836283
```
62846284

6285-
The method may be declared explicitly. It is an error if the explicit declaration does not match the expected signature or accessibility, or if the explicit declaration doesn't allow overriding it in a derived type and the record class type is not sealed. It is an error if either synthesized, or explicitly declared, method doesn't override `object.ToString()` (for example, due to shadowing in intermediate base types).
6285+
The method may be declared explicitly. It is an error if the explicit declaration does not match the expected signature or accessibility. It is an error if either synthesized, or explicitly declared, method doesn't override `object.ToString()` (for example, due to shadowing in intermediate base types).
6286+
6287+
Sealing an explicitly declared `ToString` method prevents the compiler from synthesizing a `ToString` method for any derived record types. However, this does not prevent the compiler from synthesizing `PrintMembers`.
62866288

62876289
The synthesized method:
62886290

0 commit comments

Comments
 (0)