1.3 migration: make inspections working for non-experimental coroutines
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
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 })
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
operator fun Deferred<Int>.unaryPlus() = this
|
||||
operator fun Deferred<Int>.plus(arg: Int) = this
|
||||
|
||||
fun moreFalsePositives() {
|
||||
+(async { 0 })
|
||||
async { -1 } + 1
|
||||
}
|
||||
+27
@@ -26,4 +26,31 @@
|
||||
<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>experimental.kt</file>
|
||||
<line>30</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<package><default></package>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/experimental.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>experimental.kt</file>
|
||||
<line>49</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<package><default></package>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/experimental.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>experimental.kt</file>
|
||||
<line>51</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<package><default></package>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/experimental.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,4 +1,4 @@
|
||||
package kotlinx.coroutines.experimental
|
||||
package kotlinx.coroutines
|
||||
|
||||
interface Deferred<T> {
|
||||
suspend fun await(): T
|
||||
|
||||
Reference in New Issue
Block a user