Extend "async result unused" to "Deferred result unused" #KT-15063 Fixed

This commit is contained in:
Mikhail Glukhikh
2018-05-16 12:06:21 +03:00
parent ffcfa51fbf
commit b8375d4864
15 changed files with 113 additions and 51 deletions
@@ -5,7 +5,25 @@
<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_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Deferred result is never used</problem_class>
<description>Deferred result is never used</description>
</problem>
<problem>
<file>simple.kt</file>
<line>49</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">Deferred result is never used</problem_class>
<description>Deferred result is never used</description>
</problem>
<problem>
<file>simple.kt</file>
<line>51</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">Deferred result is never used</problem_class>
<description>Deferred result is never used</description>
</problem>
</problems>
@@ -1 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.coroutines.AsyncResultUnusedInspection
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.coroutines.DeferredResultUnusedInspection
@@ -0,0 +1,3 @@
<inspection_tool class="DeferredResultUnused" enabled="true" level="WARNING" enabled_by_default="true">
<option name="standardOnly" value="false" />
</inspection_tool>
@@ -37,3 +37,18 @@ fun falsePositives() {
val res = async { 13 }
useIt(async { 7 })
}
class User
interface DbHandler {
fun getUser(id: Long): Deferred<User>
fun doStuff(): Deferred<Unit>
}
fun DbHandler.test() {
getUser(42L)
val user = getUser(42L).await()
doStuff()
doStuff().await()
}