Redundant async inspection: support case with explicit scope

#KT-28504 Fixed
This commit is contained in:
Mikhail Glukhikh
2018-11-28 16:49:39 +03:00
parent 9f5255da02
commit fd3c6496fb
9 changed files with 81 additions and 8 deletions
@@ -41,4 +41,7 @@ suspend fun <T> withContext(
suspend fun <R> coroutineScope(block: suspend CoroutineScope.() -> R): R = GlobalScope.block()
operator fun CoroutineContext.plus(other: CoroutineContext): CoroutineContext {
TODO()
}
@@ -1,9 +1,7 @@
// WITH_RUNTIME
// PROBLEM: none
package kotlinx.coroutines
suspend fun test(ctx: CoroutineContext, scope: CoroutineScope) {
// Does not work yet (1.3.11)
scope.<caret>async(ctx) { 42 }.await()
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
package kotlinx.coroutines
suspend fun test(ctx: CoroutineContext, scope: CoroutineScope) {
withContext(scope.coroutineContext + ctx) { 42 }
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
package kotlinx.coroutines
suspend fun test(ctx: CoroutineContext, scope: CoroutineScope) {
scope.<caret>async(context = ctx) { 42 }.await()
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
package kotlinx.coroutines
suspend fun test(ctx: CoroutineContext, scope: CoroutineScope) {
withContext(context = scope.coroutineContext + ctx) { 42 }
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
package kotlinx.coroutines
suspend fun test(scope: CoroutineScope) {
scope.<caret>async() { 42 }.await()
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
package kotlinx.coroutines
suspend fun test(scope: CoroutineScope) {
withContext(scope.coroutineContext) { 42 }
}