This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Commit 1bf8191
committed
Fix ValueTask behavior as async return type
There's a bug in ValueTask<T>'s builder based on a misunderstanding of what the codegen would be from the compiler. I'd thought the compiler would codegen access to the builder's Task property, but that was based on a very old model; the model actualy in place relies on the Await*OnCompleted methods doing any initialization that's necessary prior to the await. That's an important distinction, because the builder for ValueTask needs defer to the wrapped task builder's Task property once any await has been issued. Which means that rather than just delegating to the wrapped builder's Await*OnCompleted methods, before doing so the ValueTask's builder must remember that these methods have been called, such that a subsequent access will defer to the wrapped Task, even if a result is set in the interim.1 parent 380ef66 commit 1bf8191
File tree
2 files changed
+39
-3
lines changed- src/System.Threading.Tasks.Extensions
- src/System/Runtime/CompilerServices
- tests
2 files changed
+39
-3
lines changedLines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| |||
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
| 101 | + | |
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
| |||
Lines changed: 37 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
114 | 145 | | |
115 | 146 | | |
116 | 147 | | |
| |||
150 | 181 | | |
151 | 182 | | |
152 | 183 | | |
153 | | - | |
| 184 | + | |
154 | 185 | | |
155 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
156 | 190 | | |
157 | 191 | | |
158 | 192 | | |
| |||
0 commit comments