Introduce inspection "async result unused" #KT-24433 Fixed
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>simple.kt</file>
|
||||
<line>30</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<package><default></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>
|
||||
+1
@@ -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 })
|
||||
}
|
||||
Reference in New Issue
Block a user