From a7ad1113b2b1f987fd006c9adc54119556697ecf Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 30 Nov 2018 15:13:26 +0300 Subject: [PATCH] Redundant async: do not suggest for calls with 'start' The reason with 'withContext' does not have such parameter anymore --- .../inspections/coroutines/RedundantAsyncInspection.kt | 2 +- .../coroutines/redundantAsync/coroutines.lib.kt | 1 - .../coroutines/redundantAsync/withStartAndContext.kt | 1 + .../redundantAsync/withStartAndContext.kt.after | 9 --------- 4 files changed, 2 insertions(+), 11 deletions(-) delete mode 100644 idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt.after diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/coroutines/RedundantAsyncInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/coroutines/RedundantAsyncInspection.kt index a68230e6bd4..d5c9418d2b5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/coroutines/RedundantAsyncInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/coroutines/RedundantAsyncInspection.kt @@ -39,7 +39,7 @@ class RedundantAsyncInspection : AbstractCallChainChecker() { } ?: return null defaultContext ?: return null defaultStart ?: return null - if (defaultContext!! && !defaultStart!!) return null + if (!defaultStart!!) return null val receiverExpression = expression.receiverExpression val scopeExpression = (receiverExpression as? KtQualifiedExpression)?.receiverExpression diff --git a/idea/testData/inspectionsLocal/coroutines/redundantAsync/coroutines.lib.kt b/idea/testData/inspectionsLocal/coroutines/redundantAsync/coroutines.lib.kt index 94072127e34..0791bbff53c 100644 --- a/idea/testData/inspectionsLocal/coroutines/redundantAsync/coroutines.lib.kt +++ b/idea/testData/inspectionsLocal/coroutines/redundantAsync/coroutines.lib.kt @@ -33,7 +33,6 @@ fun CoroutineScope.async( suspend fun withContext( context: CoroutineContext, - start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> T ) { TODO() diff --git a/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt b/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt index a8c4abd51ae..859abfbc05c 100644 --- a/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt +++ b/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt @@ -1,4 +1,5 @@ // WITH_RUNTIME +// PROBLEM: none package kotlinx.coroutines diff --git a/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt.after b/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt.after deleted file mode 100644 index d98bbae7882..00000000000 --- a/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt.after +++ /dev/null @@ -1,9 +0,0 @@ -// WITH_RUNTIME - -package kotlinx.coroutines - -suspend fun test(ctx: CoroutineContext) { - coroutineScope { - withContext(ctx, CoroutineStart.LAZY) { 42 } - } -} \ No newline at end of file