Redundant async inspection: support case with GlobalScope

Partial implementation of KT-28504
This commit is contained in:
Mikhail Glukhikh
2018-11-28 16:25:59 +03:00
parent 138e36aa66
commit e6a1b96c53
9 changed files with 79 additions and 15 deletions
@@ -1,9 +1,7 @@
// WITH_RUNTIME
// PROBLEM: none
package kotlinx.coroutines
suspend fun test(ctx: CoroutineContext) {
// Does not work yet (1.3.11)
GlobalScope.<caret>async(ctx) { 42 }.await()
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
package kotlinx.coroutines
suspend fun test(ctx: CoroutineContext) {
withContext(ctx) { 42 }
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
package kotlinx.coroutines
suspend fun test() {
GlobalScope.<caret>async() { 42 }.await()
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
package kotlinx.coroutines
suspend fun test() {
withContext(Dispatchers.Default) { 42 }
}
@@ -0,0 +1,8 @@
// WITH_RUNTIME
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
suspend fun test() {
GlobalScope.<caret>async() { 42 }.await()
}
@@ -0,0 +1,10 @@
// WITH_RUNTIME
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.withContext
suspend fun test() {
withContext(Dispatchers.Default) { 42 }
}