Skip to content

Commit 1d55d2a

Browse files
committed
KEEP-0443-suspend-CoroutineContext-context-parameter: one more bad case if we allowed more scope pollution
1 parent 74845ee commit 1d55d2a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

proposals/KEEP-0443-suspend-CoroutineContext-context-parameter.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,15 @@ suspend fun CoroutineContext.bar() {
644644
fun CoroutineContext.baz() {}
645645
```
646646

647-
Thankfully, it's not the case.
647+
Even worse, `CoroutineContext` members would become implicitly available in `suspend` functions:
648+
649+
```kotlin
650+
suspend fun foo() {
651+
get(kotlinx.coroutines.CoroutineName) // It'd become green and resolve to CoroutineContext.get(...). That's really bad from the perspective of scope pollution
652+
}
653+
```
654+
655+
Thankfully, none of this is the case.
648656
These examples are indicators of context parameters' good design.
649657

650658
## Illustrative example. `ScopedValues`-like API for `CoroutineContext`

0 commit comments

Comments
 (0)