Skip to content

Commit 047a527

Browse files
committed
Cleanup: reduce the number of warnings during a build
1 parent 7d51152 commit 047a527

File tree

52 files changed

+237
-287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+237
-287
lines changed

buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ configure(subprojects) {
3636
"kotlinx.cinterop.ExperimentalForeignApi",
3737
"kotlinx.cinterop.UnsafeNumber",
3838
"kotlin.experimental.ExperimentalNativeApi",
39+
"kotlin.native.concurrent.ObsoleteWorkersApi",
3940
)
4041
}
4142
addExtraCompilerFlags(project)

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@file:Suppress("NAMED_ARGUMENTS_NOT_ALLOWED") // KT-21913
2-
31
package kotlinx.coroutines
42

53
import kotlinx.coroutines.testing.*
@@ -109,7 +107,7 @@ class AsyncLazyTest : TestBase() {
109107
assertTrue(!d.isActive && !d.isCompleted)
110108
try {
111109
d.await() // will throw IOException
112-
} catch (e: TestException) {
110+
} catch (_: TestException) {
113111
assertTrue(!d.isActive && d.isCompleted && d.isCancelled)
114112
expect(4)
115113
}

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@file:Suppress("NAMED_ARGUMENTS_NOT_ALLOWED", "UNREACHABLE_CODE", "USELESS_IS_CHECK") // KT-21913
2-
31
package kotlinx.coroutines
42

53
import kotlinx.coroutines.testing.*
@@ -82,11 +80,10 @@ class AsyncTest : TestBase() {
8280
val deferred = async(NonCancellable) {
8381
val decomposed = async(NonCancellable) {
8482
throw TestException()
85-
1
8683
}
8784
try {
8885
decomposed.await()
89-
} catch (e: TestException) {
86+
} catch (_: TestException) {
9087
42
9188
}
9289
}
@@ -101,29 +98,27 @@ class AsyncTest : TestBase() {
10198
val decomposed = async { // inherits parent job!
10299
expect(3)
103100
throw TestException()
104-
1
105101
}
106102
try {
107103
decomposed.await()
108-
} catch (e: TestException) {
104+
} catch (_: TestException) {
109105
expect(4) // Should catch this exception, but parent is already cancelled
110106
42
111107
}
112108
}
113109
try {
114110
// This will fail
115111
assertEquals(42, deferred.await())
116-
} catch (e: TestException) {
112+
} catch (_: TestException) {
117113
finish(5)
118114
}
119115
}
120116

121117
@Test
122118
fun testParallelDecompositionUncaughtExceptionWithInheritedParent() = runTest(expected = { it is TestException }) {
123-
val deferred = async(NonCancellable) {
119+
val deferred = async<Int>(NonCancellable) {
124120
val decomposed = async {
125121
throw TestException()
126-
1
127122
}
128123

129124
decomposed.await()
@@ -135,10 +130,9 @@ class AsyncTest : TestBase() {
135130

136131
@Test
137132
fun testParallelDecompositionUncaughtException() = runTest(expected = { it is TestException }) {
138-
val deferred = async(NonCancellable) {
133+
val deferred = async<Int>(NonCancellable) {
139134
val decomposed = async {
140135
throw TestException()
141-
1
142136
}
143137

144138
decomposed.await()
@@ -158,7 +152,7 @@ class AsyncTest : TestBase() {
158152
deferred.cancel()
159153
try {
160154
deferred.await()
161-
} catch (e: TestException) {
155+
} catch (_: TestException) {
162156
finish(3)
163157
}
164158
}
@@ -229,7 +223,7 @@ class AsyncTest : TestBase() {
229223
try {
230224
expect(1)
231225
deferred.await()
232-
} catch (e: CancellationException) {
226+
} catch (_: CancellationException) {
233227
finish(3)
234228
}
235229
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class AtomicCancellationCommonTest : TestBase() {
131131
finish(4)
132132
}
133133

134+
@Suppress("DEPRECATION")
134135
@Test
135136
fun testSelectLockCancellable() = runTest {
136137
expect(1)
@@ -151,4 +152,4 @@ class AtomicCancellationCommonTest : TestBase() {
151152
yield() // now yield
152153
finish(4)
153154
}
154-
}
155+
}

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

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@file:Suppress("NAMED_ARGUMENTS_NOT_ALLOWED") // KT-21913
2-
31
package kotlinx.coroutines
42

53
import kotlinx.coroutines.testing.*
@@ -11,15 +9,15 @@ class CancellableContinuationHandlersTest : TestBase() {
119

1210
@Test
1311
fun testDoubleSubscription() = runTest({ it is IllegalStateException }) {
14-
suspendCancellableCoroutine<Unit> { c ->
12+
suspendCancellableCoroutine { c ->
1513
c.invokeOnCancellation { finish(1) }
1614
c.invokeOnCancellation { expectUnreached() }
1715
}
1816
}
1917

2018
@Test
2119
fun testDoubleSubscriptionAfterCompletion() = runTest {
22-
suspendCancellableCoroutine<Unit> { c ->
20+
suspendCancellableCoroutine { c ->
2321
c.resume(Unit)
2422
// First invokeOnCancellation is Ok
2523
c.invokeOnCancellation { expectUnreached() }
@@ -31,7 +29,7 @@ class CancellableContinuationHandlersTest : TestBase() {
3129
@Test
3230
fun testDoubleSubscriptionAfterCompletionWithException() = runTest {
3331
assertFailsWith<TestException> {
34-
suspendCancellableCoroutine<Unit> { c ->
32+
suspendCancellableCoroutine { c ->
3533
c.resumeWithException(TestException())
3634
// First invokeOnCancellation is Ok
3735
c.invokeOnCancellation { expectUnreached() }
@@ -44,23 +42,23 @@ class CancellableContinuationHandlersTest : TestBase() {
4442
@Test
4543
fun testDoubleSubscriptionAfterCancellation() = runTest {
4644
try {
47-
suspendCancellableCoroutine<Unit> { c ->
45+
suspendCancellableCoroutine { c ->
4846
c.cancel()
4947
c.invokeOnCancellation {
5048
assertIs<CancellationException>(it)
5149
expect(1)
5250
}
5351
assertFailsWith<IllegalStateException> { c.invokeOnCancellation { expectUnreached() } }
5452
}
55-
} catch (e: CancellationException) {
53+
} catch (_: CancellationException) {
5654
finish(2)
5755
}
5856
}
5957

6058
@Test
6159
fun testSecondSubscriptionAfterCancellation() = runTest {
6260
try {
63-
suspendCancellableCoroutine<Unit> { c ->
61+
suspendCancellableCoroutine { c ->
6462
// Set IOC first
6563
c.invokeOnCancellation {
6664
assertNull(it)
@@ -72,7 +70,7 @@ class CancellableContinuationHandlersTest : TestBase() {
7270
// then try to install another one
7371
assertFailsWith<IllegalStateException> { c.invokeOnCancellation { expectUnreached() } }
7472
}
75-
} catch (e: CancellationException) {
73+
} catch (_: CancellationException) {
7674
finish(3)
7775
}
7876
}
@@ -83,7 +81,7 @@ class CancellableContinuationHandlersTest : TestBase() {
8381
val job = launch(start = CoroutineStart.UNDISPATCHED) {
8482
// will be cancelled during dispatch
8583
assertFailsWith<CancellationException> {
86-
suspendCancellableCoroutine<Unit> { c ->
84+
suspendCancellableCoroutine { c ->
8785
cont = c
8886
// Set IOC first -- not called (completed)
8987
c.invokeOnCancellation {
@@ -105,39 +103,39 @@ class CancellableContinuationHandlersTest : TestBase() {
105103
expect(6)
106104
// then try to install another one after we've done dispatching it
107105
assertFailsWith<IllegalStateException> {
108-
cont!!.invokeOnCancellation { expectUnreached() }
106+
cont.invokeOnCancellation { expectUnreached() }
109107
}
110108
finish(7)
111109
}
112110

113111
@Test
114112
fun testDoubleSubscriptionAfterCancellationWithCause() = runTest {
115113
try {
116-
suspendCancellableCoroutine<Unit> { c ->
114+
suspendCancellableCoroutine { c ->
117115
c.cancel(AssertionError())
118116
c.invokeOnCancellation {
119117
require(it is AssertionError)
120118
expect(1)
121119
}
122120
assertFailsWith<IllegalStateException> { c.invokeOnCancellation { expectUnreached() } }
123121
}
124-
} catch (e: AssertionError) {
122+
} catch (_: AssertionError) {
125123
finish(2)
126124
}
127125
}
128126

129127
@Test
130128
fun testDoubleSubscriptionMixed() = runTest {
131129
try {
132-
suspendCancellableCoroutine<Unit> { c ->
130+
suspendCancellableCoroutine { c ->
133131
c.invokeOnCancellation {
134132
require(it is IndexOutOfBoundsException)
135133
expect(1)
136134
}
137135
c.cancel(IndexOutOfBoundsException())
138136
assertFailsWith<IllegalStateException> { c.invokeOnCancellation { expectUnreached() } }
139137
}
140-
} catch (e: IndexOutOfBoundsException) {
138+
} catch (_: IndexOutOfBoundsException) {
141139
finish(2)
142140
}
143141
}
@@ -148,11 +146,11 @@ class CancellableContinuationHandlersTest : TestBase() {
148146
) {
149147
expect(1)
150148
try {
151-
suspendCancellableCoroutine<Unit> { c ->
149+
suspendCancellableCoroutine { c ->
152150
c.invokeOnCancellation { throw AssertionError() }
153151
c.cancel()
154152
}
155-
} catch (e: CancellationException) {
153+
} catch (_: CancellationException) {
156154
expect(2)
157155
}
158156
finish(3)
@@ -171,13 +169,13 @@ class CancellableContinuationHandlersTest : TestBase() {
171169
val s = MySegment()
172170
expect(1)
173171
try {
174-
suspendCancellableCoroutine<Unit> { c ->
172+
suspendCancellableCoroutine { c ->
175173
expect(2)
176174
c as CancellableContinuationImpl<*>
177175
c.invokeOnCancellation(s, 0)
178176
c.cancel()
179177
}
180-
} catch (e: CancellationException) {
178+
} catch (_: CancellationException) {
181179
expect(3)
182180
}
183181
expect(4)

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@file:Suppress("NAMED_ARGUMENTS_NOT_ALLOWED") // KT-21913
2-
31
package kotlinx.coroutines
42

53
import kotlinx.coroutines.testing.*
@@ -13,18 +11,18 @@ class CancellableContinuationTest : TestBase() {
1311
val job = launch {
1412
try {
1513
expect(2)
16-
suspendCancellableCoroutine<Unit> { c ->
14+
suspendCancellableCoroutine { c ->
1715
continuation = c
1816
}
19-
} catch (e: TestException) {
17+
} catch (_: TestException) {
2018
expect(3)
2119
}
2220
}
2321
expect(1)
2422
yield()
2523
continuation!!.resumeWithException(TestException())
2624
yield()
27-
assertFailsWith<IllegalStateException> { continuation!!.resumeWithException(TestException()) }
25+
assertFailsWith<IllegalStateException> { continuation.resumeWithException(TestException()) }
2826
job.join()
2927
finish(4)
3028
}
@@ -34,7 +32,7 @@ class CancellableContinuationTest : TestBase() {
3432
var continuation: Continuation<Unit>? = null
3533
val job = launch {
3634
expect(2)
37-
suspendCancellableCoroutine<Unit> { c ->
35+
suspendCancellableCoroutine { c ->
3836
continuation = c
3937
}
4038
expect(3)
@@ -43,7 +41,7 @@ class CancellableContinuationTest : TestBase() {
4341
yield()
4442
continuation!!.resume(Unit)
4543
job.join()
46-
assertFailsWith<IllegalStateException> { continuation!!.resumeWithException(TestException()) }
44+
assertFailsWith<IllegalStateException> { continuation.resumeWithException(TestException()) }
4745
finish(4)
4846
}
4947

@@ -52,7 +50,7 @@ class CancellableContinuationTest : TestBase() {
5250
var continuation: Continuation<Unit>? = null
5351
val job = launch {
5452
expect(2)
55-
suspendCancellableCoroutine<Unit> { c ->
53+
suspendCancellableCoroutine { c ->
5654
continuation = c
5755
}
5856
expect(3)
@@ -61,12 +59,12 @@ class CancellableContinuationTest : TestBase() {
6159
yield()
6260
continuation!!.resume(Unit)
6361
job.join()
64-
assertFailsWith<IllegalStateException> { continuation!!.resume(Unit) }
62+
assertFailsWith<IllegalStateException> { continuation.resume(Unit) }
6563
finish(4)
6664
}
6765

6866
/**
69-
* Cancelling outer job may, in practise, race with attempt to resume continuation and resumes
67+
* Cancelling the outer job may, in practice, race with an attempt to resume continuation and resumes
7068
* should be ignored. Here suspended coroutine is cancelled but then resumed with exception.
7169
*/
7270
@Test
@@ -75,10 +73,10 @@ class CancellableContinuationTest : TestBase() {
7573
val job = launch {
7674
try {
7775
expect(2)
78-
suspendCancellableCoroutine<Unit> { c ->
76+
suspendCancellableCoroutine { c ->
7977
continuation = c
8078
}
81-
} catch (e: CancellationException) {
79+
} catch (_: CancellationException) {
8280
expect(3)
8381
}
8482
}
@@ -100,10 +98,10 @@ class CancellableContinuationTest : TestBase() {
10098
val job = launch {
10199
try {
102100
expect(2)
103-
suspendCancellableCoroutine<Unit> { c ->
101+
suspendCancellableCoroutine { c ->
104102
continuation = c
105103
}
106-
} catch (e: CancellationException) {
104+
} catch (_: CancellationException) {
107105
expect(3)
108106
}
109107
}

0 commit comments

Comments
 (0)