Skip to content

Commit b5a8493

Browse files
LouisCADelizarov
authored andcommitted
Replace unneeded type parameter with projection
Type parameter of awaitClose is not used but produces a warning in new type inference when used with builder inference as in callbackFlow as seen in this issue: https://youtrack.jetbrains.com/issue/KT-32097 Using star projection removes the warning and is binary compatible thanks to generics type erasure.
1 parent 583d39d commit b5a8493

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

kotlinx-coroutines-core/common/src/channels/Produce.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public interface ProducerScope<in E> : CoroutineScope, SendChannel<E> {
4242
* ```
4343
*/
4444
@ExperimentalCoroutinesApi
45-
public suspend fun <T> ProducerScope<T>.awaitClose(block: () -> Unit = {}) {
45+
public suspend fun ProducerScope<*>.awaitClose(block: () -> Unit = {}) {
4646
check(kotlin.coroutines.coroutineContext[Job] === this) { "awaitClose() can be invoke only from the producer context" }
4747
try {
4848
suspendCancellableCoroutine<Unit> { cont ->

kotlinx-coroutines-core/common/test/channels/ProduceTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class ProduceTest : TestBase() {
145145
fun testAwaitIllegalState() = runTest {
146146
val channel = produce<Int> { }
147147
@Suppress("RemoveExplicitTypeArguments") // KT-31525
148-
assertFailsWith<IllegalStateException> { (channel as ProducerScope<*>).awaitClose<Nothing>() }
148+
assertFailsWith<IllegalStateException> { (channel as ProducerScope<*>).awaitClose() }
149149
}
150150

151151
private suspend fun cancelOnCompletion(coroutineContext: CoroutineContext) = CoroutineScope(coroutineContext).apply {

0 commit comments

Comments
 (0)