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
public Enumerator GetAsyncEnumerator() => new Enumerator();
@@ -2085,20 +2088,28 @@ public ref struct Enumerator
2085
2088
2086
2089
varexpectedDiagnostics=new[]
2087
2090
{
2088
-
// (6,15): error CS8344: foreach statement cannot operate on enumerators of type 'C.Enumerator' in async or iterator methods because 'C.Enumerator' is a ref struct.
2091
+
// (6,9): error CS4007: Instance of type 'C.Enumerator' cannot be preserved across 'await' or 'yield' boundary.
@@ -2107,8 +2118,9 @@ public static async IAsyncEnumerable<int> M()
2107
2118
{
2108
2119
await foreach (var x in new C())
2109
2120
{
2110
-
yield return x;
2121
+
{{body}}
2111
2122
}
2123
+
yield return -1;
2112
2124
}
2113
2125
public Enumerator GetAsyncEnumerator() => new Enumerator();
2114
2126
public ref struct Enumerator
@@ -2117,18 +2129,21 @@ public ref struct Enumerator
2117
2129
public Task<bool> MoveNextAsync() => throw null;
2118
2130
}
2119
2131
}
2120
-
"""+s_IAsyncEnumerable;
2132
+
"""+AsyncStreamsTypes;
2121
2133
2122
2134
varexpectedDiagnostics=new[]
2123
2135
{
2124
-
// (7,15): error CS8344: foreach statement cannot operate on enumerators of type 'C.Enumerator' in async or iterator methods because 'C.Enumerator' is a ref struct.
2136
+
// (7,9): error CS4007: Instance of type 'C.Enumerator' cannot be preserved across 'await' or 'yield' boundary.
@@ -2156,14 +2171,17 @@ public ref struct Enumerator
2156
2171
2157
2172
varexpectedDiagnostics=new[]
2158
2173
{
2159
-
// (6,9): error CS8344: foreach statement cannot operate on enumerators of type 'C.Enumerator' in async or iterator methods because 'C.Enumerator' is a ref struct.
2174
+
// (6,9): error CS4007: Instance of type 'C.Enumerator' cannot be preserved across 'await' or 'yield' boundary.
0 commit comments