Skip to content

Commit e264843

Browse files
committed
Enable allWarningsAsErrors in core module as well
1 parent b61fe8d commit e264843

File tree

10 files changed

+33
-11
lines changed

10 files changed

+33
-11
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
@@ -24,6 +24,7 @@ val graduallyIntroducedWarningAsErrorProjects = setOf(
2424
"kotlinx-coroutines-slf4j",
2525

2626
// Top-level
27+
"kotlinx-coroutines-core",
2728
"kotlinx-coroutines-debug",
2829

2930
)

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5+
@file:Suppress("UNCHECKED_CAST", "UNUSED_PARAMETER")
6+
57
package kotlinx.coroutines.channels
68

79
import kotlinx.atomicfu.*
@@ -16,6 +18,7 @@ import kotlin.jvm.*
1618
/**
1719
* Abstract send channel. It is a base class for all send channel implementations.
1820
*/
21+
@Suppress("UNCHECKED_CAST", "UNUSED_PARAMETER")
1922
internal abstract class AbstractSendChannel<E>(
2023
@JvmField protected val onUndeliveredElement: OnUndeliveredElement<E>?
2124
) : SendChannel<E> {
@@ -122,7 +125,12 @@ internal abstract class AbstractSendChannel<E>(
122125
return sendSuspend(element)
123126
}
124127

125-
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
128+
@Suppress("DEPRECATION_ERROR")
129+
@Deprecated(
130+
level = DeprecationLevel.ERROR,
131+
message = "Deprecated in the favour of 'trySend' method",
132+
replaceWith = ReplaceWith("trySend(element).isSuccess")
133+
) // see super()
126134
override fun offer(element: E): Boolean {
127135
// Temporary migration for offer users who rely on onUndeliveredElement
128136
try {
@@ -705,6 +713,11 @@ internal abstract class AbstractChannel<E>(
705713
onCancellationConstructor = onUndeliveredElementReceiveCancellationConstructor
706714
)
707715

716+
@Deprecated(
717+
message = "Deprecated in favor of onReceiveCatching extension",
718+
level = DeprecationLevel.ERROR,
719+
replaceWith = ReplaceWith("onReceiveCatching")
720+
) // See super()
708721
override val onReceiveOrNull: SelectClause1<E?>
709722
get() = SelectClause1Impl<E?>(
710723
clauseObject = this,
@@ -726,7 +739,7 @@ internal abstract class AbstractChannel<E>(
726739
if (selectResult is Closed<*>) throw selectResult.receiveException
727740
else selectResult as E
728741

729-
private fun processResultSelectReceiveCatching(ignoredParam: Any?, selectResult: Any?): Any? =
742+
private fun processResultSelectReceiveCatching(ignoredParam: Any?, selectResult: Any?): Any =
730743
if (selectResult is Closed<*>) ChannelResult.closed(selectResult.closeCause)
731744
else ChannelResult.success(selectResult as E)
732745

@@ -735,8 +748,8 @@ internal abstract class AbstractChannel<E>(
735748
else selectResult as E
736749

737750
private val onUndeliveredElementReceiveCancellationConstructor: OnCancellationConstructor? = onUndeliveredElement?.let {
738-
{ select: SelectInstance<*>, ignoredParam: Any?, element: Any? ->
739-
{ cause: Throwable -> if (element !is Closed<*>) onUndeliveredElement.callUndeliveredElement(element as E, select.context) }
751+
{ select: SelectInstance<*>, _: Any?, element: Any? ->
752+
{ _: Throwable -> if (element !is Closed<*>) onUndeliveredElement.callUndeliveredElement(element as E, select.context) }
740753
}
741754
}
742755

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ internal open class ArrayChannel<E>(
158158
// Too late, already cancelled, but we removed it from the queue and need to notify on undelivered element.
159159
// The only exception is when this "send" operation is an `onSend` clause that has to be re-registered
160160
// in the corresponding `select` invocation.
161+
@Suppress("NAME_SHADOWING")
161162
val send = send!!
162163
if (!(send is SendElementSelectWithUndeliveredHandler<*> && send.trySelectResult == REREGISTER))
163164
send.undeliveredElement()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ public fun <E> ReceiveChannel<E>.broadcast(
4747
start: CoroutineStart = CoroutineStart.LAZY
4848
): BroadcastChannel<E> {
4949
val scope = GlobalScope + Dispatchers.Unconfined + CoroutineExceptionHandler { _, _ -> }
50+
val channel = this
5051
// We can run this coroutine in the context that ignores all exceptions, because of `onCompletion = consume()`
5152
// which passes all exceptions upstream to the source ReceiveChannel
5253
return scope.broadcast(capacity = capacity, start = start, onCompletion = { cancelConsumed(it) }) {
53-
for (e in this@broadcast) {
54+
for (e in channel) {
5455
send(e)
5556
}
5657
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ public interface ReceiveChannel<out E> {
360360
*
361361
* @suppress **Deprecated**: in favor of onReceiveCatching extension.
362362
*/
363+
@Suppress("DEPRECATION_ERROR")
363364
@Deprecated(
364365
message = "Deprecated in favor of onReceiveCatching extension",
365366
level = DeprecationLevel.ERROR,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ internal class DispatchedContinuation<in T>(
207207

208208
// We inline it to save an entry on the stack in cases where it shows (unconfined dispatcher)
209209
// It is used only in Continuation<T>.resumeCancellableWith
210+
@Suppress("NOTHING_TO_INLINE")
210211
inline fun resumeCancellableWith(
211212
result: Result<T>,
212213
noinline onCancellation: ((cause: Throwable) -> Unit)?
@@ -235,7 +236,7 @@ internal class DispatchedContinuation<in T>(
235236
}
236237

237238
// inline here is to save us an entry on the stack for the sake of better stacktraces
238-
239+
@Suppress("NOTHING_TO_INLINE")
239240
inline fun resumeCancelled(state: Any?): Boolean {
240241
val job = context[Job]
241242
if (job != null && !job.isActive) {
@@ -247,6 +248,7 @@ internal class DispatchedContinuation<in T>(
247248
return false
248249
}
249250

251+
@Suppress("NOTHING_TO_INLINE")
250252
inline fun resumeUndispatchedWith(result: Result<T>) {
251253
withContinuationContext(continuation, countOrElement) {
252254
continuation.resumeWith(result)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ internal fun <T> DispatchedTask<T>.dispatch(mode: Int) {
167167
}
168168
}
169169

170-
@Suppress("UNCHECKED_CAST")
171170
internal fun <T> DispatchedTask<T>.resume(delegate: Continuation<T>, undispatched: Boolean) {
172171
// This resume is never cancellable. The result is always delivered to delegate continuation.
173172
val state = takeState()

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,12 @@ private class LazyActorCoroutine<E>(
162162
return super.send(element)
163163
}
164164

165-
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
165+
@Suppress("DEPRECATION_ERROR")
166+
@Deprecated(
167+
level = DeprecationLevel.ERROR,
168+
message = "Deprecated in the favour of 'trySend' method",
169+
replaceWith = ReplaceWith("trySend(element).isSuccess")
170+
) // See super()
166171
override fun offer(element: E): Boolean {
167172
start()
168173
return super.offer(element)
@@ -181,6 +186,7 @@ private class LazyActorCoroutine<E>(
181186
return closed
182187
}
183188

189+
@Suppress("UNCHECKED_CAST")
184190
override val onSend: SelectClause2<E, SendChannel<E>> get() = SelectClause2Impl(
185191
clauseObject = this,
186192
regFunc = LazyActorCoroutine<*>::onSendRegFunction as RegistrationFunction,

kotlinx-coroutines-core/jvm/src/debug/AgentPremain.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ internal object AgentPremain {
2626
}.getOrNull() ?: DebugProbesImpl.enableCreationStackTraces
2727

2828
@JvmStatic
29+
@Suppress("UNUSED_PARAMETER")
2930
fun premain(args: String?, instrumentation: Instrumentation) {
3031
AgentInstallationType.isInstalledStatically = true
3132
instrumentation.addTransformer(DebugProbesTransformer)

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ private class MissingMainCoroutineDispatcher(
9898
override fun limitedParallelism(parallelism: Int): CoroutineDispatcher =
9999
missing()
100100

101-
override suspend fun delay(time: Long) =
102-
missing()
103-
104101
override fun invokeOnTimeout(timeMillis: Long, block: Runnable, context: CoroutineContext): DisposableHandle =
105102
missing()
106103

0 commit comments

Comments
 (0)