Skip to content

Commit ca135a2

Browse files
committed
Fix and suppress some compilation warnings
1 parent d88e427 commit ca135a2

File tree

13 files changed

+26
-10
lines changed

13 files changed

+26
-10
lines changed

common/kotlinx-coroutines-core-common/src/SchedulerTask.common.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ internal expect abstract class SchedulerTask() : Runnable
88

99
internal expect interface SchedulerTaskContext
1010

11+
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
1112
internal expect val SchedulerTask.taskContext: SchedulerTaskContext
1213

14+
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
1315
internal expect inline fun SchedulerTaskContext.afterTask()

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ public suspend inline fun <E> BroadcastChannel<E>.consumeEach(action: (E) -> Uni
6060
* See [issue #254](https://github.com/Kotlin/kotlinx.coroutines/issues/254).
6161
*/
6262
@ObsoleteCoroutinesApi
63-
public fun ReceiveChannel<*>.consumes(): CompletionHandler =
64-
{ cause: Throwable? -> cancel(cause) }
63+
public fun ReceiveChannel<*>.consumes(): CompletionHandler = { cause: Throwable? ->
64+
@Suppress("DEPRECATION")
65+
cancel(cause)
66+
}
6567

6668
/**
6769
* Returns a [CompletionHandler] that invokes [cancel][ReceiveChannel.cancel] on all the
@@ -77,6 +79,7 @@ public fun consumesAll(vararg channels: ReceiveChannel<*>): CompletionHandler =
7779
var exception: Throwable? = null
7880
for (channel in channels)
7981
try {
82+
@Suppress("DEPRECATION")
8083
channel.cancel(cause)
8184
} catch (e: Throwable) {
8285
if (exception == null) {
@@ -112,6 +115,7 @@ public inline fun <E, R> ReceiveChannel<E>.consume(block: ReceiveChannel<E>.() -
112115
cause = e
113116
throw e
114117
} finally {
118+
@Suppress("DEPRECATION")
115119
cancel(cause)
116120
}
117121
}
@@ -302,7 +306,7 @@ public suspend fun <E> ReceiveChannel<E>.firstOrNull(): E? =
302306
* See [issue #254](https://github.com/Kotlin/kotlinx.coroutines/issues/254).
303307
*/
304308
@ObsoleteCoroutinesApi
305-
public inline suspend fun <E> ReceiveChannel<E>.firstOrNull(predicate: (E) -> Boolean): E? {
309+
public suspend inline fun <E> ReceiveChannel<E>.firstOrNull(predicate: (E) -> Boolean): E? {
306310
consumeEach {
307311
if (predicate(it)) return it
308312
}

common/kotlinx-coroutines-core-common/test/AbstractCoroutineTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package kotlinx.coroutines
77
import kotlin.coroutines.*
88
import kotlin.test.*
99

10+
@Suppress("DEPRECATION") // cancel(cause)
1011
class AbstractCoroutineTest : TestBase() {
1112
@Test
1213
fun testNotifications() = runTest {

common/kotlinx-coroutines-core-common/test/AsyncTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package kotlinx.coroutines
88

99
import kotlin.test.*
1010

11+
@Suppress("DEPRECATION") // cancel(cause)
1112
class AsyncTest : TestBase() {
1213

1314
@Test

core/kotlinx-coroutines-core/src/Builders.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ private class BlockingCoroutine<T>(
6565
fun joinBlocking(): T {
6666
timeSource.registerTimeLoopThread()
6767
while (true) {
68+
@Suppress("DEPRECATION")
6869
if (Thread.interrupted()) throw InterruptedException().also { cancel(it) }
6970
val parkNanos = eventLoop?.processNextEvent() ?: Long.MAX_VALUE
7071
// note: process next even may loose unpark flag, so check if completed before parking

core/kotlinx-coroutines-core/src/channels/Actor.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ private open class ActorCoroutine<E>(
128128
active: Boolean
129129
) : ChannelCoroutine<E>(parentContext, channel, active), ActorScope<E> {
130130
override fun onCancellation(cause: Throwable?) {
131+
@Suppress("DEPRECATION")
131132
_channel.cancel(cause)
132133
}
133134

core/kotlinx-coroutines-core/test/TestBase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public actual open class TestBase actual constructor() {
157157
var exCount = 0
158158
var ex: Throwable? = null
159159
try {
160-
runBlocking(block = block, context = CoroutineExceptionHandler { context, e ->
160+
runBlocking(block = block, context = CoroutineExceptionHandler { _, e ->
161161
if (e is CancellationException) return@CoroutineExceptionHandler // are ignored
162162
exCount++
163163
when {

core/kotlinx-coroutines-core/test/exceptions/JobBasicCancellationTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import kotlin.test.*
1414
* parent is not cancelled on child cancellation and launch {}, Job(), async {} and
1515
* CompletableDeferred behave properly
1616
*/
17+
18+
@Suppress("DEPRECATION") // cancel(cause)
1719
class JobBasicCancellationTest : TestBase() {
1820

1921
@Test

core/kotlinx-coroutines-core/test/exceptions/JobExceptionHandlingTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import org.junit.Test
1010
import java.io.*
1111
import kotlin.test.*
1212

13+
@Suppress("DEPRECATION") // cancel(cause)
1314
class JobExceptionHandlingTest : TestBase() {
1415

1516
@Test

core/kotlinx-coroutines-core/test/exceptions/SuppresionTests.kt renamed to core/kotlinx-coroutines-core/test/exceptions/SuppressionTests.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@
55
package kotlinx.coroutines.exceptions
66

77
import kotlinx.coroutines.*
8-
import kotlinx.coroutines.exceptions.*
9-
import kotlinx.coroutines.selects.*
108
import java.io.*
119
import kotlin.coroutines.*
1210
import kotlin.test.*
1311

1412
/*
1513
* Set of counterparts to common tests which check suppressed exceptions
1614
*/
17-
class SuppresionTests : TestBase() {
15+
@Suppress("DEPRECATION")
16+
class SuppressionTests : TestBase() {
1817

1918
@Test
2019
fun testCancellationTransparency() = runTest {
@@ -45,7 +44,7 @@ class SuppresionTests : TestBase() {
4544

4645
override fun onCancellation(cause: Throwable?) {
4746
assertTrue(cause is ArithmeticException)
48-
assertTrue(cause!!.suppressed.isEmpty())
47+
assertTrue(cause.suppressed.isEmpty())
4948
expect(5)
5049
}
5150

@@ -62,13 +61,13 @@ class SuppresionTests : TestBase() {
6261

6362
coroutine.invokeOnCompletion(onCancelling = true) {
6463
assertTrue(it is ArithmeticException)
65-
assertTrue(it!!.suppressed.isEmpty())
64+
assertTrue(it.suppressed.isEmpty())
6665
expect(6)
6766
}
6867

6968
coroutine.invokeOnCompletion {
7069
assertTrue(it is ArithmeticException)
71-
checkException<IOException>(it!!.suppressed[0])
70+
checkException<IOException>(it.suppressed[0])
7271
expect(8)
7372
}
7473

core/kotlinx-coroutines-core/test/exceptions/WithContextCancellationStressTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class WithContextCancellationStressTest : TestBase() {
2323
}
2424

2525
@Test
26+
@Suppress("DEPRECATION")
2627
fun testConcurrentCancellation() = runBlocking {
2728
var ioException = 0
2829
var arithmeticException = 0

core/kotlinx-coroutines-core/test/exceptions/WithContextExceptionHandlingTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import java.io.*
1212
import kotlin.coroutines.*
1313
import kotlin.test.*
1414

15+
@Suppress("DEPRECATION") // cancel(cause)
1516
@RunWith(Parameterized::class)
1617
class WithContextExceptionHandlingTest(private val mode: Mode) : TestBase() {
1718
enum class Mode { WITH_CONTEXT, ASYNC_AWAIT }

core/kotlinx-coroutines-core/test/scheduling/SchedulerTestBase.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5+
@file:Suppress("UNUSED_VARIABLE")
6+
57
package kotlinx.coroutines.scheduling
68

79
import kotlinx.atomicfu.*

0 commit comments

Comments
 (0)