@@ -24,40 +24,45 @@ import kotlin.coroutines.*
2424 * when the parent is cancelled, the whole parent-child relation between parent and child is severed.
2525 * The parent will not wait for the child's completion, nor will be cancelled when the child crashed.
2626 */
27+ @Suppress(" DeprecatedCallableAddReplaceWith" )
2728public object NonCancellable : AbstractCoroutineContextElement(Job ), Job {
29+
30+ private const val message = " NonCancellable can be used only as an argument for 'withContext', direct usages of its API are prohibited"
31+
2832 /* *
2933 * Always returns `true`.
3034 * @suppress **This an internal API and should not be used from general code.**
3135 */
32- @InternalCoroutinesApi
33- override val isActive: Boolean get() = true
36+ @Deprecated(level = DeprecationLevel .WARNING , message = message)
37+ override val isActive: Boolean
38+ get() = true
3439
3540 /* *
3641 * Always returns `false`.
3742 * @suppress **This an internal API and should not be used from general code.**
3843 */
39- @InternalCoroutinesApi
44+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
4045 override val isCompleted: Boolean get() = false
4146
4247 /* *
4348 * Always returns `false`.
4449 * @suppress **This an internal API and should not be used from general code.**
4550 */
46- @InternalCoroutinesApi
51+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
4752 override val isCancelled: Boolean get() = false
4853
4954 /* *
5055 * Always returns `false`.
5156 * @suppress **This an internal API and should not be used from general code.**
5257 */
53- @InternalCoroutinesApi
58+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
5459 override fun start (): Boolean = false
5560
5661 /* *
5762 * Always throws [UnsupportedOperationException].
5863 * @suppress **This an internal API and should not be used from general code.**
5964 */
60- @InternalCoroutinesApi
65+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
6166 override suspend fun join () {
6267 throw UnsupportedOperationException (" This job is always active" )
6368 }
@@ -66,37 +71,37 @@ public object NonCancellable : AbstractCoroutineContextElement(Job), Job {
6671 * Always throws [UnsupportedOperationException].
6772 * @suppress **This an internal API and should not be used from general code.**
6873 */
74+ @Deprecated(level = DeprecationLevel .WARNING , message = message)
6975 override val onJoin: SelectClause0
7076 get() = throw UnsupportedOperationException (" This job is always active" )
7177
7278 /* *
7379 * Always throws [IllegalStateException].
7480 * @suppress **This an internal API and should not be used from general code.**
7581 */
76- @InternalCoroutinesApi
82+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
7783 override fun getCancellationException (): CancellationException = throw IllegalStateException (" This job is always active" )
7884
7985 /* *
8086 * @suppress **This an internal API and should not be used from general code.**
8187 */
82- @Suppress(" OverridingDeprecatedMember" )
83- @InternalCoroutinesApi
88+ @Deprecated(level = DeprecationLevel .WARNING , message = message)
8489 override fun invokeOnCompletion (handler : CompletionHandler ): DisposableHandle =
8590 NonDisposableHandle
8691
8792 /* *
8893 * Always returns no-op handle.
8994 * @suppress **This an internal API and should not be used from general code.**
9095 */
91- @InternalCoroutinesApi
96+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
9297 override fun invokeOnCompletion (onCancelling : Boolean , invokeImmediately : Boolean , handler : CompletionHandler ): DisposableHandle =
9398 NonDisposableHandle
9499
95100 /* *
96101 * Does nothing.
97102 * @suppress **This an internal API and should not be used from general code.**
98103 */
99- @InternalCoroutinesApi
104+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
100105 override fun cancel (cause : CancellationException ? ) {}
101106
102107 /* *
@@ -110,15 +115,15 @@ public object NonCancellable : AbstractCoroutineContextElement(Job), Job {
110115 * Always returns [emptySequence].
111116 * @suppress **This an internal API and should not be used from general code.**
112117 */
113- @InternalCoroutinesApi
118+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
114119 override val children: Sequence <Job >
115120 get() = emptySequence()
116121
117122 /* *
118123 * Always returns [NonDisposableHandle] and does not do anything.
119124 * @suppress **This an internal API and should not be used from general code.**
120125 */
121- @InternalCoroutinesApi
126+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
122127 override fun attachChild (child : ChildJob ): ChildHandle = NonDisposableHandle
123128
124129 /* * @suppress */
0 commit comments