Commit d1c583a
authored
Add the EXACTLY_ONCE contract to
`suspendCancellableContinuation` invokes its block exactly once.
`suspendCoroutineUninterceptedOrReturn`,
which is used for implementing `suspendCancellableContinuation`,
already has a contract stating just that,
so for consistency and completeness, we add a contract to
`suspendCancellableContinuation` itself as well.
This will let the compiler recognize that `val`-variables can be
safely assigned inside the lambda, as they won't be reassigned
or left uninitialized (which would be the case if the lambda
executed more than once or possibly not execute at all).
There were no use cases actually reported for this.suspendCancellableContinuation (#4574)1 parent ebad555 commit d1c583a
File tree
2 files changed
+17
-2
lines changed- kotlinx-coroutines-core/common
- src
- test
2 files changed
+17
-2
lines changedLines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
424 | 425 | | |
425 | 426 | | |
426 | 427 | | |
| 428 | + | |
427 | 429 | | |
428 | 430 | | |
429 | | - | |
430 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
431 | 434 | | |
432 | 435 | | |
433 | 436 | | |
| |||
438 | 441 | | |
439 | 442 | | |
440 | 443 | | |
| 444 | + | |
441 | 445 | | |
442 | 446 | | |
443 | 447 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
137 | 148 | | |
0 commit comments