Skip to content

Commit

Permalink
Restore allWarningsAsErrors in main source-sets (#4336)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwwdfsad authored Feb 11, 2025
1 parent 2d89b24 commit b1711eb
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ configure(subprojects) {
apiVersion = it
versionsAreNotOverridden = false
}
if (isMainTaskName && versionsAreNotOverridden && !unpublished.contains(project.name)) {
if (isMainTaskName && !unpublished.contains(project.name)) {
allWarningsAsErrors = true
freeCompilerArgs.add("-Xexplicit-api=strict")
freeCompilerArgs.addAll("-Xexplicit-api=strict", "-Xdont-warn-on-error-suppression")
}
/* Coroutines do not interop with Java and these flags provide a significant
* (i.e. close to double-digit) reduction in both bytecode and optimized dex size */
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
version=1.10.1-SNAPSHOT
group=org.jetbrains.kotlinx
kotlin_version=2.1.0
kotlin_language_version=2.1
# DO NOT rename this property without adapting kotlinx.train build chain:
atomicfu_version=0.26.1

Expand Down
4 changes: 1 addition & 3 deletions kotlinx-coroutines-core/common/src/Builders.common.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@file:JvmMultifileClass
@file:JvmName("BuildersKt")
@file:OptIn(ExperimentalContracts::class)
@file:Suppress("LEAKED_IN_PLACE_LAMBDA", "WRONG_INVOCATION_KIND")

package kotlinx.coroutines

Expand Down Expand Up @@ -153,7 +154,6 @@ public suspend fun <T> withContext(
// FAST PATH #1 -- new context is the same as the old one
if (newContext === oldContext) {
val coroutine = ScopeCoroutine(newContext, uCont)
@Suppress("LEAKED_IN_PLACE_LAMBDA") // Contract is preserved, invoked immediately or throws
return@sc coroutine.startUndispatchedOrReturn(coroutine, block)
}
// FAST PATH #2 -- the new dispatcher is the same as the old one (something else changed)
Expand All @@ -162,13 +162,11 @@ public suspend fun <T> withContext(
val coroutine = UndispatchedCoroutine(newContext, uCont)
// There are changes in the context, so this thread needs to be updated
withCoroutineContext(coroutine.context, null) {
@Suppress("LEAKED_IN_PLACE_LAMBDA") // Contract is preserved, invoked immediately or throws
return@sc coroutine.startUndispatchedOrReturn(coroutine, block)
}
}
// SLOW PATH -- use new dispatcher
val coroutine = DispatchedCoroutine(newContext, uCont)
@Suppress("LEAKED_IN_PLACE_LAMBDA") // Contract is preserved, invoked immediately or throws
block.startCoroutineCancellable(coroutine, coroutine)
coroutine.getResult()
}
Expand Down
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/common/src/CoroutineScope.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@file:OptIn(ExperimentalContracts::class)
@file:Suppress("LEAKED_IN_PLACE_LAMBDA", "WRONG_INVOCATION_KIND")

package kotlinx.coroutines

Expand Down Expand Up @@ -281,7 +282,6 @@ public suspend fun <R> coroutineScope(block: suspend CoroutineScope.() -> R): R
}
return suspendCoroutineUninterceptedOrReturn { uCont ->
val coroutine = ScopeCoroutine(uCont.context, uCont)
@Suppress("LEAKED_IN_PLACE_LAMBDA") // Contract is preserved, invoked immediately or throws
coroutine.startUndispatchedOrReturn(coroutine, block)
}
}
Expand Down
3 changes: 1 addition & 2 deletions kotlinx-coroutines-core/common/src/Supervisor.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@file:OptIn(ExperimentalContracts::class)
@file:Suppress("DEPRECATION_ERROR")
@file:Suppress("LEAKED_IN_PLACE_LAMBDA", "WRONG_INVOCATION_KIND")

package kotlinx.coroutines

Expand Down Expand Up @@ -53,7 +53,6 @@ public suspend fun <R> supervisorScope(block: suspend CoroutineScope.() -> R): R
}
return suspendCoroutineUninterceptedOrReturn { uCont ->
val coroutine = SupervisorCoroutine(uCont.context, uCont)
@Suppress("LEAKED_IN_PLACE_LAMBDA") // Contract is preserved, invoked immediately or throws
coroutine.startUndispatchedOrReturn(coroutine, block)
}
}
Expand Down
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/common/src/Timeout.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@file:OptIn(ExperimentalContracts::class)
@file:Suppress("LEAKED_IN_PLACE_LAMBDA", "WRONG_INVOCATION_KIND")

package kotlinx.coroutines

Expand Down Expand Up @@ -40,7 +41,6 @@ public suspend fun <T> withTimeout(timeMillis: Long, block: suspend CoroutineSco
}
if (timeMillis <= 0L) throw TimeoutCancellationException("Timed out immediately")
return suspendCoroutineUninterceptedOrReturn { uCont ->
@Suppress("LEAKED_IN_PLACE_LAMBDA") // Contract is preserved, invoked immediately or throws
setupTimeout(TimeoutCoroutine(timeMillis, uCont), block)
}
}
Expand Down
2 changes: 0 additions & 2 deletions kotlinx-coroutines-core/common/src/channels/Channel.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("FunctionName")

package kotlinx.coroutines.channels

import kotlinx.coroutines.*
Expand Down
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/common/src/flow/Migration.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@file:JvmMultifileClass
@file:JvmName("FlowKt")
@file:Suppress("unused", "DeprecatedCallableAddReplaceWith", "UNUSED_PARAMETER", "NO_EXPLICIT_RETURN_TYPE_IN_API_MODE")
@file:Suppress("unused", "DeprecatedCallableAddReplaceWith", "UNUSED_PARAMETER")

package kotlinx.coroutines.flow

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE")

package kotlinx.coroutines.internal

/** @suppress **This is unstable API and it is subject to change.** */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("LEAKED_IN_PLACE_LAMBDA", "WRONG_INVOCATION_KIND")

package kotlinx.coroutines.internal

import kotlinx.coroutines.*
Expand All @@ -24,6 +26,5 @@ public inline fun <T> synchronized(lock: SynchronizedObject, block: () -> T): T
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
@Suppress("LEAKED_IN_PLACE_LAMBDA") // Contract is preserved, invoked immediately or throws
return synchronizedImpl(lock, block)
}
1 change: 1 addition & 0 deletions kotlinx-coroutines-core/jvm/src/Builders.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@file:JvmMultifileClass
@file:JvmName("BuildersKt")
@file:OptIn(ExperimentalContracts::class)
@file:Suppress("LEAKED_IN_PLACE_LAMBDA", "WRONG_INVOCATION_KIND")

package kotlinx.coroutines

Expand Down
1 change: 1 addition & 0 deletions kotlinx-coroutines-core/jvm/src/channels/Actor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public fun <E> CoroutineScope.actor(
return coroutine
}

@Suppress("MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE_DEPRECATION_WARNING")
private open class ActorCoroutine<E>(
parentContext: CoroutineContext,
channel: Channel<E>,
Expand Down
3 changes: 2 additions & 1 deletion kotlinx-coroutines-core/native/src/Builders.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@file:OptIn(ExperimentalContracts::class, ObsoleteWorkersApi::class)
@file:Suppress("LEAKED_IN_PLACE_LAMBDA", "WRONG_INVOCATION_KIND")

package kotlinx.coroutines

import kotlinx.cinterop.*
Expand Down Expand Up @@ -64,7 +66,6 @@ public actual fun <T> runBlocking(context: CoroutineContext, block: suspend Coro
var completed = false
ThreadLocalKeepAlive.addCheck { !completed }
try {
@Suppress("LEAKED_IN_PLACE_LAMBDA") // Contract is preserved, invoked immediately or throws
coroutine.start(CoroutineStart.DEFAULT, coroutine, block)
return coroutine.joinBlocking()
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ public class TestCoroutineDispatcher(public override val scheduler: TestCoroutin
private fun post(block: Runnable, context: CoroutineContext) =
scheduler.registerEvent(this, 0, block, context) { false }

val currentTime: Long
public val currentTime: Long
get() = scheduler.currentTime

fun advanceUntilIdle(): Long {
public fun advanceUntilIdle(): Long {
val oldTime = scheduler.currentTime
scheduler.advanceUntilIdle()
return scheduler.currentTime - oldTime
}

fun runCurrent(): Unit = scheduler.runCurrent()
public fun runCurrent(): Unit = scheduler.runCurrent()

fun cleanupTestCoroutines() {
public fun cleanupTestCoroutines() {
// process any pending cancellations or completions, but don't advance time
scheduler.runCurrent()
if (!scheduler.isIdle(strict = false)) {
Expand Down
1 change: 1 addition & 0 deletions kotlinx-coroutines-test/wasmJs/src/TestBuilders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import kotlin.js.*

public actual typealias TestResult = JsPromiseInterfaceForTesting

@Suppress("INFERRED_TYPE_VARIABLE_INTO_POSSIBLE_EMPTY_INTERSECTION")
internal actual fun createTestResult(testProcedure: suspend CoroutineScope.() -> Unit): TestResult =
GlobalScope.promise {
testProcedure()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public final class kotlinx/coroutines/reactive/FlowSubscription : kotlinx/corout
public final field flow Lkotlinx/coroutines/flow/Flow;
public final field subscriber Lorg/reactivestreams/Subscriber;
public fun <init> (Lkotlinx/coroutines/flow/Flow;Lorg/reactivestreams/Subscriber;Lkotlin/coroutines/CoroutineContext;)V
public fun cancel ()V
public synthetic fun cancel ()V
public fun request (J)V
}

Expand Down
1 change: 1 addition & 0 deletions reactive/kotlinx-coroutines-reactive/src/Publish.kt
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ public class PublisherCoroutine<in T>(
signalCompleted(cause, handled)
}

@Suppress("OVERRIDE_DEPRECATION") // Remove after 2.2.0
override fun cancel() {
// Specification requires that after cancellation publisher stops signalling
// This flag distinguishes subscription cancellation request from the job crash
Expand Down
1 change: 1 addition & 0 deletions reactive/kotlinx-coroutines-reactive/src/ReactiveFlow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public class FlowSubscription<T>(
}
}

@Deprecated("Since 1.2.0, binary compatibility with versions <= 1.1.x", level = DeprecationLevel.HIDDEN)
override fun cancel() {
cancellationRequested = true
cancel(null)
Expand Down

0 comments on commit b1711eb

Please sign in to comment.