Skip to content

Conversation

@BillWagner
Copy link
Member

Fixes #928

The PR for readonly members in structs did not add text that a temporary copy of this wasn't required to invoke a readonly member. (The clause in structs did state that a copy wasn't required, but that left the spec in an inconsistent state.

Fixes dotnet#928

The PR for readonly members in structs did not add text that a temporary copy of `this` wasn't required to invoke a readonly member. (The clause in structs did state that a copy wasn't required, but that left the spec in an inconsistent state.
Make two changes to cover property accessors in structs and the `readonly` modifier.

First, in expressions, add a note that property accessors are classified as function member access: A property access invokes the corresponding function member. So, the same rules apply.
Second, in structs differences, add that accessing a non-readonly setter when that requires creating a temporary is a compile-time error. In the case of a getter, the temporary is created if the getter is not classified as `readonly`.
@BillWagner BillWagner added the meeting: discuss This issue should be discussed at the next TC49-TG2 meeting label Jul 9, 2025
@jskeet jskeet merged commit c641e7c into dotnet:draft-v8 Jul 30, 2025
6 checks passed
@BillWagner BillWagner deleted the readonly-temporary branch July 30, 2025 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meeting: discuss This issue should be discussed at the next TC49-TG2 meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C# 8.0] 12.6.6.1 should not require a defensive copy to invoke a readonly member

3 participants