Skip to content

Commit 691261e

Browse files
qwwdfsadpablobaxter
authored andcommitted
Migrate from deprecated API and fix compilation warnings where possible
1 parent 8c61118 commit 691261e

File tree

8 files changed

+15
-10
lines changed

8 files changed

+15
-10
lines changed

gradle.properties

+1
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ jekyll_version=4.0
5656
org.gradle.jvmargs=-Xmx4g
5757

5858
kotlin.mpp.enableCompatibilityMetadataVariant=true
59+
kotlin.mpp.stability.nowarn=true

gradle/opt-in.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

55
ext.optInAnnotations = [
6+
"kotlin.RequiresOptIn",
67
"kotlin.experimental.ExperimentalTypeInference",
78
"kotlin.ExperimentalMultiplatform",
89
"kotlinx.coroutines.DelicateCoroutinesApi",

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

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ internal abstract class AbstractSendChannel<E>(
136136
return sendSuspend(element)
137137
}
138138

139+
@Suppress("DEPRECATION")
139140
override fun offer(element: E): Boolean {
140141
// Temporary migration for offer users who rely on onUndeliveredElement
141142
try {

kotlinx-coroutines-core/common/src/flow/SharedFlow.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ private class SharedFlowImpl<T>(
469469
// outside of the lock: register dispose on cancellation
470470
emitter?.let { cont.disposeOnCancellation(it) }
471471
// outside of the lock: resume slots if needed
472-
for (cont in resumes) cont?.resume(Unit)
472+
for (r in resumes) r?.resume(Unit)
473473
}
474474

475475
private fun cancelEmitter(emitter: Emitter) = synchronized(this) {

kotlinx-coroutines-core/common/src/internal/StackTraceRecovery.common.kt

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ internal expect fun <E: Throwable> recoverStackTrace(exception: E, continuation:
2020
/**
2121
* initCause on JVM, nop on other platforms
2222
*/
23+
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
2324
internal expect fun Throwable.initCause(cause: Throwable)
2425

2526
/**

kotlinx-coroutines-core/common/test/selects/SelectTimeoutDurationTest.kt

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ class SelectTimeoutDurationTest : TestBase() {
1414
fun testBasic() = runTest {
1515
expect(1)
1616
val result = select<String> {
17-
onTimeout(1000.milliseconds) {
17+
onTimeout(Duration.milliseconds(1000)) {
1818
expectUnreached()
1919
"FAIL"
2020
}
21-
onTimeout(100.milliseconds) {
21+
onTimeout(Duration.milliseconds(100)) {
2222
expect(2)
2323
"OK"
2424
}
25-
onTimeout(500.milliseconds) {
25+
onTimeout(Duration.milliseconds(500)) {
2626
expectUnreached()
2727
"FAIL"
2828
}
@@ -35,7 +35,7 @@ class SelectTimeoutDurationTest : TestBase() {
3535
fun testZeroTimeout() = runTest {
3636
expect(1)
3737
val result = select<String> {
38-
onTimeout(1.seconds) {
38+
onTimeout(Duration.seconds(1)) {
3939
expectUnreached()
4040
"FAIL"
4141
}
@@ -52,11 +52,11 @@ class SelectTimeoutDurationTest : TestBase() {
5252
fun testNegativeTimeout() = runTest {
5353
expect(1)
5454
val result = select<String> {
55-
onTimeout(1.seconds) {
55+
onTimeout(Duration.seconds(1)) {
5656
expectUnreached()
5757
"FAIL"
5858
}
59-
onTimeout(-10.milliseconds) {
59+
onTimeout(-Duration.milliseconds(10)) {
6060
expect(2)
6161
"OK"
6262
}
@@ -71,13 +71,13 @@ class SelectTimeoutDurationTest : TestBase() {
7171
val iterations =10_000
7272
for (i in 0..iterations) {
7373
val result = selectUnbiased<Int> {
74-
onTimeout(-1.seconds) {
74+
onTimeout(-Duration.seconds(1)) {
7575
0
7676
}
7777
onTimeout(Duration.ZERO) {
7878
1
7979
}
80-
onTimeout(1.seconds) {
80+
onTimeout(Duration.seconds(1)) {
8181
expectUnreached()
8282
2
8383
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ private class LazyActorCoroutine<E>(
163163
return super.send(element)
164164
}
165165

166-
@Suppress("DEPRECATION_ERROR")
166+
@Suppress("DEPRECATION")
167167
override fun offer(element: E): Boolean {
168168
start()
169169
return super.offer(element)

kotlinx-coroutines-core/jvm/src/internal/StackTraceRecovery.kt

+1
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ internal actual typealias CoroutineStackFrame = kotlin.coroutines.jvm.internal.C
216216
@Suppress("ACTUAL_WITHOUT_EXPECT")
217217
internal actual typealias StackTraceElement = java.lang.StackTraceElement
218218

219+
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
219220
internal actual fun Throwable.initCause(cause: Throwable) {
220221
// Resolved to member, verified by test
221222
initCause(cause)

0 commit comments

Comments
 (0)