Introduce inspection "async result unused" #KT-24433 Fixed

This commit is contained in:
Mikhail Glukhikh
2018-05-15 18:42:12 +03:00
parent d0c045e4ba
commit ffcfa51fbf
13 changed files with 180 additions and 1 deletions
@@ -0,0 +1,11 @@
<problems>
<problem>
<file>simple.kt</file>
<line>30</line>
<module>light_idea_test_case</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/simple.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Result of 'async' is not used</problem_class>
<description>Result of 'async' is never used</description>
</problem>
</problems>
@@ -0,0 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.coroutines.AsyncResultUnusedInspection
@@ -0,0 +1,39 @@
package kotlinx.coroutines.experimental
interface Deferred<T> {
suspend fun await(): T
}
interface CoroutineContext
object DefaultContext : CoroutineContext
enum class CoroutineStart {
DEFAULT,
LAZY,
ATOMIC,
UNDISPATCHED
}
interface Job
fun <T> async(
context: CoroutineContext = DefaultContext,
start: CoroutineStart = CoroutineStart.DEFAULT,
parent: Job? = null,
f: suspend () -> T
): Deferred<T> {
TODO()
}
fun test() {
async { 42 }
}
fun useIt(d: Deferred<Int>) {}
fun falsePositives() {
async { 3 }.await()
val res = async { 13 }
useIt(async { 7 })
}