Skip to content

Commit 0ab8933

Browse files
committed
Analysis: Resolve opt-in experimental coroutines api warnings
1st Warning Messages: "This declaration is experimental and its usage should be marked with '@kotlinx.coroutines.ExperimentalCoroutinesApi' or '@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)'" Adding the '@OptIn(ExperimentalCoroutinesApi::class)' annotation on these functions is the recommended action to resolve this 'GlobalScope' warnings. However, this results to the below '@OptIn' warnings: 2nd Warning Message: "This annotation should be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'" Adding the '-Xopt-in=kotlin.RequiresOptIn' free compiler argument is the recommended action to resolve this '@OptIn' warning.
1 parent 3fec60c commit 0ab8933

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

WordPress/src/main/java/org/wordpress/android/models/usecases/LocalCommentCacheUpdateHandler.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.wordpress.android.models.usecases
22

3+
import kotlinx.coroutines.ExperimentalCoroutinesApi
34
import kotlinx.coroutines.flow.merge
45
import org.wordpress.android.models.usecases.LocalCommentCacheUpdateUseCase.PropagateCommentsUpdateAction.UpdatedComments
56
import javax.inject.Inject
@@ -11,6 +12,7 @@ class LocalCommentCacheUpdateHandler @Inject constructor(
1112
) {
1213
private val useCases = listOf(localCommentCacheUpdateUseCase)
1314

15+
@OptIn(ExperimentalCoroutinesApi::class)
1416
fun subscribe() = useCases.map { it.subscribe() }.merge()
1517

1618
suspend fun requestCommentsUpdate() = localCommentCacheUpdateUseCase.manageAction(

WordPress/src/main/java/org/wordpress/android/models/usecases/UnifiedCommentsListHandler.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.wordpress.android.models.usecases
22

3+
import kotlinx.coroutines.ExperimentalCoroutinesApi
34
import kotlinx.coroutines.flow.merge
45
import org.wordpress.android.models.usecases.BatchModerateCommentsUseCase.ModerateCommentsAction.OnModerateComments
56
import org.wordpress.android.models.usecases.BatchModerateCommentsUseCase.Parameters.ModerateCommentsParameters
@@ -21,6 +22,7 @@ class UnifiedCommentsListHandler @Inject constructor(
2122
) {
2223
private val useCases = listOf(paginateCommentsUseCase, batchModerationUseCase, moderationWithUndoUseCase)
2324

25+
@OptIn(ExperimentalCoroutinesApi::class)
2426
fun subscribe() = useCases.map { it.subscribe() }.merge()
2527

2628
suspend fun requestPage(parameters: GetPageParameters) = paginateCommentsUseCase.manageAction(

WordPress/src/main/java/org/wordpress/android/ui/utils/ConcurrentContinuationWrapper.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.wordpress.android.ui.utils
22

33
import kotlinx.coroutines.CancellableContinuation
4+
import kotlinx.coroutines.ExperimentalCoroutinesApi
45
import kotlinx.coroutines.suspendCancellableCoroutine
56

67
class ConcurrentContinuationWrapper<T> : ContinuationWrapper<T> {
@@ -18,6 +19,7 @@ class ConcurrentContinuationWrapper<T> : ContinuationWrapper<T> {
1819
}
1920
}
2021

22+
@OptIn(ExperimentalCoroutinesApi::class)
2123
override fun continueWith(t: T) {
2224
continuationList.removeFirstOrNull()?.let {
2325
if (it.isActive) {

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ allprojects {
113113
tasks.withType(KotlinCompile).all {
114114
kotlinOptions {
115115
jvmTarget = JavaVersion.VERSION_1_8
116+
freeCompilerArgs += [
117+
"-Xopt-in=kotlin.RequiresOptIn"
118+
]
116119
}
117120
}
118121
}

0 commit comments

Comments
 (0)