@@ -24,40 +24,45 @@ import kotlin.coroutines.*
24
24
* when the parent is cancelled, the whole parent-child relation between parent and child is severed.
25
25
* The parent will not wait for the child's completion, nor will be cancelled when the child crashed.
26
26
*/
27
+ @Suppress(" DeprecatedCallableAddReplaceWith" )
27
28
public 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
+
28
32
/* *
29
33
* Always returns `true`.
30
34
* @suppress **This an internal API and should not be used from general code.**
31
35
*/
32
- @InternalCoroutinesApi
33
- override val isActive: Boolean get() = true
36
+ @Deprecated(level = DeprecationLevel .WARNING , message = message)
37
+ override val isActive: Boolean
38
+ get() = true
34
39
35
40
/* *
36
41
* Always returns `false`.
37
42
* @suppress **This an internal API and should not be used from general code.**
38
43
*/
39
- @InternalCoroutinesApi
44
+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
40
45
override val isCompleted: Boolean get() = false
41
46
42
47
/* *
43
48
* Always returns `false`.
44
49
* @suppress **This an internal API and should not be used from general code.**
45
50
*/
46
- @InternalCoroutinesApi
51
+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
47
52
override val isCancelled: Boolean get() = false
48
53
49
54
/* *
50
55
* Always returns `false`.
51
56
* @suppress **This an internal API and should not be used from general code.**
52
57
*/
53
- @InternalCoroutinesApi
58
+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
54
59
override fun start (): Boolean = false
55
60
56
61
/* *
57
62
* Always throws [UnsupportedOperationException].
58
63
* @suppress **This an internal API and should not be used from general code.**
59
64
*/
60
- @InternalCoroutinesApi
65
+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
61
66
override suspend fun join () {
62
67
throw UnsupportedOperationException (" This job is always active" )
63
68
}
@@ -66,37 +71,37 @@ public object NonCancellable : AbstractCoroutineContextElement(Job), Job {
66
71
* Always throws [UnsupportedOperationException].
67
72
* @suppress **This an internal API and should not be used from general code.**
68
73
*/
74
+ @Deprecated(level = DeprecationLevel .WARNING , message = message)
69
75
override val onJoin: SelectClause0
70
76
get() = throw UnsupportedOperationException (" This job is always active" )
71
77
72
78
/* *
73
79
* Always throws [IllegalStateException].
74
80
* @suppress **This an internal API and should not be used from general code.**
75
81
*/
76
- @InternalCoroutinesApi
82
+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
77
83
override fun getCancellationException (): CancellationException = throw IllegalStateException (" This job is always active" )
78
84
79
85
/* *
80
86
* @suppress **This an internal API and should not be used from general code.**
81
87
*/
82
- @Suppress(" OverridingDeprecatedMember" )
83
- @InternalCoroutinesApi
88
+ @Deprecated(level = DeprecationLevel .WARNING , message = message)
84
89
override fun invokeOnCompletion (handler : CompletionHandler ): DisposableHandle =
85
90
NonDisposableHandle
86
91
87
92
/* *
88
93
* Always returns no-op handle.
89
94
* @suppress **This an internal API and should not be used from general code.**
90
95
*/
91
- @InternalCoroutinesApi
96
+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
92
97
override fun invokeOnCompletion (onCancelling : Boolean , invokeImmediately : Boolean , handler : CompletionHandler ): DisposableHandle =
93
98
NonDisposableHandle
94
99
95
100
/* *
96
101
* Does nothing.
97
102
* @suppress **This an internal API and should not be used from general code.**
98
103
*/
99
- @InternalCoroutinesApi
104
+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
100
105
override fun cancel (cause : CancellationException ? ) {}
101
106
102
107
/* *
@@ -110,15 +115,15 @@ public object NonCancellable : AbstractCoroutineContextElement(Job), Job {
110
115
* Always returns [emptySequence].
111
116
* @suppress **This an internal API and should not be used from general code.**
112
117
*/
113
- @InternalCoroutinesApi
118
+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
114
119
override val children: Sequence <Job >
115
120
get() = emptySequence()
116
121
117
122
/* *
118
123
* Always returns [NonDisposableHandle] and does not do anything.
119
124
* @suppress **This an internal API and should not be used from general code.**
120
125
*/
121
- @InternalCoroutinesApi
126
+ @Deprecated(level = DeprecationLevel . WARNING , message = message)
122
127
override fun attachChild (child : ChildJob ): ChildHandle = NonDisposableHandle
123
128
124
129
/* * @suppress */
0 commit comments