Clean up kotlin warnings for lifecycle library.
Bug: 134925073
Test: ./gradlew assembleDebug
Change-Id: Ibdd5f010d9add1614e024269ca3d70a5a23a467a
diff --git a/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt b/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt
index e65b15b..af856e4 100644
--- a/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt
@@ -193,9 +193,7 @@
}
}
is KotlinBasePluginWrapper -> {
- if (project.name == "lifecycle-runtime-ktx" || // b/134925073
- project.name == "lifecycle-livedata-ktx" || // b/134925073
- project.name == "benchmark") { // b/134925431
+ if (project.name == "benchmark") { // b/134925431
return@all
}
project.tasks.withType(KotlinCompile::class.java).configureEach { compile ->
diff --git a/lifecycle/lifecycle-livedata-ktx/build.gradle b/lifecycle/lifecycle-livedata-ktx/build.gradle
index 8cafa70..b289a13 100644
--- a/lifecycle/lifecycle-livedata-ktx/build.gradle
+++ b/lifecycle/lifecycle-livedata-ktx/build.gradle
@@ -33,6 +33,10 @@
}
}
+tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
+ kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlin.Experimental"]
+}
+
dependencies {
api(project(":lifecycle:lifecycle-livedata"))
api(project(":lifecycle:lifecycle-livedata-core-ktx"))
diff --git a/lifecycle/lifecycle-runtime-ktx/src/androidTest/java/androidx/lifecycle/FakeLifecycleOwner.kt b/lifecycle/lifecycle-runtime-ktx/src/androidTest/java/androidx/lifecycle/FakeLifecycleOwner.kt
index a817e38..136bcff 100644
--- a/lifecycle/lifecycle-runtime-ktx/src/androidTest/java/androidx/lifecycle/FakeLifecycleOwner.kt
+++ b/lifecycle/lifecycle-runtime-ktx/src/androidTest/java/androidx/lifecycle/FakeLifecycleOwner.kt
@@ -65,7 +65,7 @@
}
}
- private suspend fun getObserverCount(count: Int): Int {
+ private suspend fun getObserverCount(): Int {
return withContext(Dispatchers.Main) {
registry.observerCount
}
diff --git a/lifecycle/lifecycle-runtime-ktx/src/main/java/androidx/lifecycle/DispatchQueue.kt b/lifecycle/lifecycle-runtime-ktx/src/main/java/androidx/lifecycle/DispatchQueue.kt
index 4f71877..7ace839 100644
--- a/lifecycle/lifecycle-runtime-ktx/src/main/java/androidx/lifecycle/DispatchQueue.kt
+++ b/lifecycle/lifecycle-runtime-ktx/src/main/java/androidx/lifecycle/DispatchQueue.kt
@@ -20,6 +20,7 @@
import androidx.annotation.AnyThread
import androidx.annotation.MainThread
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.ExperimentalCoroutinesApi
import java.util.ArrayDeque
import java.util.Queue
import kotlin.coroutines.EmptyCoroutineContext
@@ -86,6 +87,7 @@
private fun canRun() = finished || !paused
@AnyThread
+ @ExperimentalCoroutinesApi
@SuppressLint("WrongThread") // false negative, we are checking the thread
fun runOrEnqueue(runnable: Runnable) {
Dispatchers.Main.immediate.dispatch(EmptyCoroutineContext, Runnable {
diff --git a/lifecycle/lifecycle-runtime-ktx/src/main/java/androidx/lifecycle/PausingDispatcher.kt b/lifecycle/lifecycle-runtime-ktx/src/main/java/androidx/lifecycle/PausingDispatcher.kt
index d40e75d..ffc821c 100644
--- a/lifecycle/lifecycle-runtime-ktx/src/main/java/androidx/lifecycle/PausingDispatcher.kt
+++ b/lifecycle/lifecycle-runtime-ktx/src/main/java/androidx/lifecycle/PausingDispatcher.kt
@@ -19,6 +19,7 @@
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
import kotlinx.coroutines.Runnable
import kotlinx.coroutines.withContext
@@ -178,6 +179,7 @@
@JvmField
internal val dispatchQueue = DispatchQueue()
+ @ExperimentalCoroutinesApi
override fun dispatch(context: CoroutineContext, block: Runnable) {
dispatchQueue.runOrEnqueue(block)
}