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
Copy file name to clipboardExpand all lines: proposals/KEEP-0443-suspend-CoroutineContext-context-parameter.md
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,17 +108,25 @@ Goals:
108
108
3. Bridge `suspend` and context parameters features together, making the language to work as a whole
109
109
110
110
The proposal is to treat all `suspend` functions
111
-
as if their bodies were implicitly enclosed within `context(getContinuation_compiler_intrinsic().context) { /* the rest of the body... */ }`stdlib function:
111
+
as if their bodies were implicitly enclosed within `context(getContinuation_compiler_intrinsic().context) { /* the rest of the body... */ }`block:
112
112
113
113
```kotlin
114
-
suspendfuncomputation() =/* implicitly enclosed within */ context(getContinuation_compiler_intrinsic().context) {
115
-
foo() //Green code
114
+
suspendfuncomputation() {
115
+
foo() //The result of this proposal is that the code becomes green. In the current Kotlin, the code is red
116
116
}
117
117
118
118
context(_:CoroutineContext)
119
119
funfoo() {}
120
120
```
121
121
122
+
The code above works because the compiler encloses the `suspend` function body within the `context` block:
0 commit comments