Skip to content

Commit b61fe8d

Browse files
committed
Enable warnings as errors where appropriate
1 parent 6f3d4f5 commit b61fe8d

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,45 @@
44

55
import org.jetbrains.kotlin.gradle.tasks.*
66

7+
val graduallyIntroducedWarningAsErrorProjects = setOf(
8+
// UI
9+
"kotlinx-coroutines-android",
10+
"kotlinx-coroutines-javafx",
11+
"kotlinx-coroutines-swing",
12+
13+
// Reactive
14+
"kotlinx-coroutines-jdk9",
15+
"kotlinx-coroutines-reactive",
16+
"kotlinx-coroutines-reactor",
17+
"kotlinx-coroutines-rx2",
18+
"kotlinx-coroutines-rx3",
19+
20+
// Integration
21+
"kotlinx-coroutines-guava",
22+
"kotlinx-coroutines-jdk8",
23+
"kotlinx-coroutines-play-services",
24+
"kotlinx-coroutines-slf4j",
25+
26+
// Top-level
27+
"kotlinx-coroutines-debug",
28+
29+
)
30+
731
configure(subprojects) {
832
if (name in sourceless) return@configure
933
apply(plugin = "kotlinx-atomicfu")
34+
val projectName = name
1035
tasks.withType(KotlinCompile::class).all {
36+
val isMainTaskName = name == "compileKotlin" || name == "compileKotlinJvm"
1137
kotlinOptions {
38+
if (projectName in graduallyIntroducedWarningAsErrorProjects && isMainTaskName) {
39+
allWarningsAsErrors = true
40+
}
1241
val newOptions =
1342
listOf(
1443
"-progressive", "-Xno-param-assertions", "-Xno-receiver-assertions",
1544
"-Xno-call-assertions"
16-
) + optInAnnotations.map { "-Xopt-in=$it" }
45+
) + optInAnnotations.map { "-opt-in=$it" }
1746
freeCompilerArgs = freeCompilerArgs + newOptions
1847
}
1948
}

reactive/kotlinx-coroutines-reactor/src/ReactorFlow.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ private class FlowAsFlux<T : Any>(
3232
private val flow: Flow<T>,
3333
private val context: CoroutineContext
3434
) : Flux<T>() {
35-
override fun subscribe(subscriber: CoreSubscriber<in T>?) {
36-
if (subscriber == null) throw NullPointerException()
35+
override fun subscribe(subscriber: CoreSubscriber<in T>) {
3736
val hasContext = !subscriber.currentContext().isEmpty
3837
val source = if (hasContext) flow.flowOn(subscriber.currentContext().asCoroutineContext()) else flow
3938
subscriber.onSubscribe(FlowSubscription(source, subscriber, context))

reactive/kotlinx-coroutines-rx3/src/RxMaybe.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ private class RxMaybeCoroutine<T>(
4343
) : AbstractCoroutine<T>(parentContext, false, true) {
4444
override fun onCompleted(value: T) {
4545
try {
46+
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") // KT-54201
4647
if (value == null) subscriber.onComplete() else subscriber.onSuccess(value)
4748
} catch (e: Throwable) {
4849
handleUndeliverableException(e, context)

0 commit comments

Comments
 (0)