Skip to content

Commit 9c9af7f

Browse files
committed
Add deprecation notices
1 parent 03664f7 commit 9c9af7f

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

kotlinx-coroutines-test/common/src/migration/DelayController.kt

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import kotlinx.coroutines.*
1717
"Use `TestCoroutineScheduler` to control virtual time.",
1818
level = DeprecationLevel.WARNING
1919
)
20+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
2021
public interface DelayController {
2122
/**
2223
* Returns the current virtual clock-time as it is known to this Dispatcher.
@@ -106,6 +107,7 @@ public interface DelayController {
106107
"Please use a dispatcher that is paused by default, like `StandardTestDispatcher`.",
107108
level = DeprecationLevel.WARNING
108109
)
110+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
109111
public suspend fun pauseDispatcher(block: suspend () -> Unit)
110112

111113
/**
@@ -118,6 +120,7 @@ public interface DelayController {
118120
"Please use a dispatcher that is paused by default, like `StandardTestDispatcher`.",
119121
level = DeprecationLevel.WARNING
120122
)
123+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
121124
public fun pauseDispatcher()
122125

123126
/**
@@ -131,6 +134,7 @@ public interface DelayController {
131134
"Please use a dispatcher that is paused by default, like `StandardTestDispatcher`.",
132135
level = DeprecationLevel.WARNING
133136
)
137+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
134138
public fun resumeDispatcher()
135139
}
136140

@@ -143,6 +147,7 @@ internal interface SchedulerAsDelayController : DelayController {
143147
ReplaceWith("this.scheduler.currentTime"),
144148
level = DeprecationLevel.WARNING
145149
)
150+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
146151
override val currentTime: Long
147152
get() = scheduler.currentTime
148153

@@ -153,6 +158,7 @@ internal interface SchedulerAsDelayController : DelayController {
153158
ReplaceWith("this.scheduler.apply { advanceTimeBy(delayTimeMillis); runCurrent() }"),
154159
level = DeprecationLevel.WARNING
155160
)
161+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
156162
override fun advanceTimeBy(delayTimeMillis: Long): Long {
157163
val oldTime = scheduler.currentTime
158164
scheduler.advanceTimeBy(delayTimeMillis)
@@ -166,6 +172,7 @@ internal interface SchedulerAsDelayController : DelayController {
166172
ReplaceWith("this.scheduler.advanceUntilIdle()"),
167173
level = DeprecationLevel.WARNING
168174
)
175+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
169176
override fun advanceUntilIdle(): Long {
170177
val oldTime = scheduler.currentTime
171178
scheduler.advanceUntilIdle()
@@ -178,6 +185,7 @@ internal interface SchedulerAsDelayController : DelayController {
178185
ReplaceWith("this.scheduler.runCurrent()"),
179186
level = DeprecationLevel.WARNING
180187
)
188+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
181189
override fun runCurrent(): Unit = scheduler.runCurrent()
182190

183191
/** @suppress */

kotlinx-coroutines-test/common/src/migration/TestBuildersDeprecated.kt

+7
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import kotlin.jvm.*
4747
* @param testBody The code of the unit-test.
4848
*/
4949
@Deprecated("Use `runTest` instead to support completing from other dispatchers.", level = DeprecationLevel.WARNING)
50+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
5051
public fun runBlockingTest(
5152
context: CoroutineContext = EmptyCoroutineContext,
5253
testBody: suspend TestCoroutineScope.() -> Unit
@@ -67,6 +68,7 @@ public fun runBlockingTest(
6768
* A version of [runBlockingTest] that works with [TestScope].
6869
*/
6970
@Deprecated("Use `runTest` instead to support completing from other dispatchers.", level = DeprecationLevel.WARNING)
71+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
7072
public fun runBlockingTestOnTestScope(
7173
context: CoroutineContext = EmptyCoroutineContext,
7274
testBody: suspend TestScope.() -> Unit
@@ -92,20 +94,23 @@ public fun runBlockingTestOnTestScope(
9294
* Convenience method for calling [runBlockingTest] on an existing [TestCoroutineScope].
9395
*/
9496
@Deprecated("Use `runTest` instead to support completing from other dispatchers.", level = DeprecationLevel.WARNING)
97+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
9598
public fun TestCoroutineScope.runBlockingTest(block: suspend TestCoroutineScope.() -> Unit): Unit =
9699
runBlockingTest(coroutineContext, block)
97100

98101
/**
99102
* Convenience method for calling [runBlockingTestOnTestScope] on an existing [TestScope].
100103
*/
101104
@Deprecated("Use `runTest` instead to support completing from other dispatchers.", level = DeprecationLevel.WARNING)
105+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
102106
public fun TestScope.runBlockingTest(block: suspend TestScope.() -> Unit): Unit =
103107
runBlockingTestOnTestScope(coroutineContext, block)
104108

105109
/**
106110
* Convenience method for calling [runBlockingTest] on an existing [TestCoroutineDispatcher].
107111
*/
108112
@Deprecated("Use `runTest` instead to support completing from other dispatchers.", level = DeprecationLevel.WARNING)
113+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
109114
public fun TestCoroutineDispatcher.runBlockingTest(block: suspend TestCoroutineScope.() -> Unit): Unit =
110115
runBlockingTest(this, block)
111116

@@ -114,6 +119,7 @@ public fun TestCoroutineDispatcher.runBlockingTest(block: suspend TestCoroutineS
114119
*/
115120
@ExperimentalCoroutinesApi
116121
@Deprecated("Use `runTest` instead.", level = DeprecationLevel.WARNING)
122+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
117123
public fun runTestWithLegacyScope(
118124
context: CoroutineContext = EmptyCoroutineContext,
119125
dispatchTimeoutMs: Long = DEFAULT_DISPATCH_TIMEOUT_MS,
@@ -147,6 +153,7 @@ public fun runTestWithLegacyScope(
147153
*/
148154
@ExperimentalCoroutinesApi
149155
@Deprecated("Use `TestScope.runTest` instead.", level = DeprecationLevel.WARNING)
156+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
150157
public fun TestCoroutineScope.runTest(
151158
dispatchTimeoutMs: Long = DEFAULT_DISPATCH_TIMEOUT_MS,
152159
block: suspend TestCoroutineScope.() -> Unit

kotlinx-coroutines-test/common/src/migration/TestCoroutineDispatcher.kt

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import kotlin.coroutines.*
2424
@Deprecated("The execution order of `TestCoroutineDispatcher` can be confusing, and the mechanism of " +
2525
"pausing is typically misunderstood. Please use `StandardTestDispatcher` or `UnconfinedTestDispatcher` instead.",
2626
level = DeprecationLevel.WARNING)
27+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
2728
public class TestCoroutineDispatcher(public override val scheduler: TestCoroutineScheduler = TestCoroutineScheduler()):
2829
TestDispatcher(), Delay, SchedulerAsDelayController
2930
{

kotlinx-coroutines-test/common/src/migration/TestCoroutineExceptionHandler.kt

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import kotlin.coroutines.*
1818
"please report your use case at https://github.com/Kotlin/kotlinx.coroutines/issues.",
1919
level = DeprecationLevel.WARNING
2020
)
21+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
2122
public interface UncaughtExceptionCaptor {
2223
/**
2324
* List of uncaught coroutine exceptions.
@@ -46,6 +47,7 @@ public interface UncaughtExceptionCaptor {
4647
"It may be to define one's own `CoroutineExceptionHandler` if you just need to handle '" +
4748
"uncaught exceptions without a special `TestCoroutineScope` integration.", level = DeprecationLevel.WARNING
4849
)
50+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
4951
public class TestCoroutineExceptionHandler :
5052
AbstractCoroutineContextElement(CoroutineExceptionHandler), CoroutineExceptionHandler, UncaughtExceptionCaptor {
5153
private val _exceptions = mutableListOf<Throwable>()

kotlinx-coroutines-test/common/src/migration/TestCoroutineScope.kt

+9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import kotlin.coroutines.*
1414
*/
1515
@ExperimentalCoroutinesApi
1616
@Deprecated("Use `TestScope` in combination with `runTest` instead")
17+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
1718
public sealed interface TestCoroutineScope : CoroutineScope {
1819
/**
1920
* Called after the test completes.
@@ -35,6 +36,8 @@ public sealed interface TestCoroutineScope : CoroutineScope {
3536
* @throws IllegalStateException if called more than once.
3637
*/
3738
@ExperimentalCoroutinesApi
39+
@Deprecated("Please call `runTest`, which automatically performs the cleanup, instead of using this function.")
40+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
3841
public fun cleanupTestCoroutines()
3942

4043
/**
@@ -127,6 +130,7 @@ internal fun CoroutineContext.activeJobs(): Set<Job> {
127130
),
128131
level = DeprecationLevel.WARNING
129132
)
133+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
130134
public fun TestCoroutineScope(context: CoroutineContext = EmptyCoroutineContext): TestCoroutineScope {
131135
val scheduler = context[TestCoroutineScheduler] ?: TestCoroutineScheduler()
132136
return createTestCoroutineScope(TestCoroutineDispatcher(scheduler) + TestCoroutineExceptionHandler() + context)
@@ -163,6 +167,7 @@ public fun TestCoroutineScope(context: CoroutineContext = EmptyCoroutineContext)
163167
"Please use TestScope() construction instead, or just runTest(), without creating a scope.",
164168
level = DeprecationLevel.WARNING
165169
)
170+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
166171
public fun createTestCoroutineScope(context: CoroutineContext = EmptyCoroutineContext): TestCoroutineScope {
167172
val ctxWithDispatcher = context.withDelaySkipping()
168173
var scope: TestCoroutineScopeImpl? = null
@@ -222,6 +227,7 @@ public val TestCoroutineScope.currentTime: Long
222227
ReplaceWith("this.testScheduler.apply { advanceTimeBy(delayTimeMillis); runCurrent() }"),
223228
DeprecationLevel.WARNING
224229
)
230+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
225231
public fun TestCoroutineScope.advanceTimeBy(delayTimeMillis: Long): Unit =
226232
when (val controller = coroutineContext.delayController) {
227233
null -> {
@@ -265,6 +271,7 @@ public fun TestCoroutineScope.runCurrent() {
265271
),
266272
DeprecationLevel.WARNING
267273
)
274+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
268275
public suspend fun TestCoroutineScope.pauseDispatcher(block: suspend () -> Unit) {
269276
delayControllerForPausing.pauseDispatcher(block)
270277
}
@@ -280,6 +287,7 @@ public suspend fun TestCoroutineScope.pauseDispatcher(block: suspend () -> Unit)
280287
),
281288
level = DeprecationLevel.WARNING
282289
)
290+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
283291
public fun TestCoroutineScope.pauseDispatcher() {
284292
delayControllerForPausing.pauseDispatcher()
285293
}
@@ -295,6 +303,7 @@ public fun TestCoroutineScope.pauseDispatcher() {
295303
),
296304
level = DeprecationLevel.WARNING
297305
)
306+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
298307
public fun TestCoroutineScope.resumeDispatcher() {
299308
delayControllerForPausing.resumeDispatcher()
300309
}

0 commit comments

Comments
 (0)