You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Item 45: §16.2.3 Restructure ref struct restriction list
Restructure the bullet list so all items grammatically complete the lead-in "It is a compile-time error if a ref struct type is used in any of the following contexts:". Several items are currently standalone statements (e.g., "There is no conversion from...") that don't fit the lead-in.
Copy file name to clipboardExpand all lines: standard/structs.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,16 +69,18 @@ It is a compile-time error if a ref struct type is used in any of the following
69
69
70
70
- As the element type of an array.
71
71
- As the declared type of a field of a class or a struct that does not have the `ref` modifier.
72
-
- Being boxed to `System.ValueType` or `System.Object`.
73
72
- As a type argument.
74
73
- As the type of a tuple element.
75
-
- An async method.
76
-
- An iterator.
77
-
- There is no conversion from a `ref struct` type to the type `object` or the type `System.ValueType`.
74
+
- In an async method.
75
+
- In an iterator.
76
+
- As the receiver type for a method group conversion to a delegate type.
77
+
- As a captured variable in a lambda expression or a local function.
78
+
79
+
In addition, the following restrictions apply to a `ref struct` type:
80
+
81
+
- A `ref struct` type shall not be boxed to `System.ValueType` or `System.Object`.
78
82
- A `ref struct` type shall not be declared to implement any interface.
79
83
- An instance method declared in `object` or in `System.ValueType` but not overridden in a `ref struct` type shall not be called with a receiver of that `ref struct` type.
80
-
- An instance method of a `ref struct` type shall not be captured by method group conversion to a delegate type.
81
-
- A ref struct shall not be captured by a lambda expression or a local function.
82
84
83
85
> *Note*: A `ref struct` shall not declare `async` instance methods nor use a `yield return` or `yield break` statement within an instance method, because the implicit `this` parameter cannot be used in those contexts. *end note*
0 commit comments