FIR: introduce NON_LOCAL_SUSPENSION_POINT diagnostic

This commit is contained in:
Mikhail Glukhikh
2021-07-23 13:28:10 +03:00
committed by teamcityserver
parent 8f1d07084b
commit 2397650c24
15 changed files with 42 additions and 125 deletions
@@ -14,5 +14,5 @@ suspend fun insideJob3() = doTheJob3()
fun doTheJob0() = simpleAsync0 { <!ARGUMENT_TYPE_MISMATCH!>insideJob0()<!> }
fun doTheJob1() = simpleAsync1 { <!ARGUMENT_TYPE_MISMATCH!>insideJob1()<!> }
suspend fun doTheJob2() = simpleAsync2 { <!ARGUMENT_TYPE_MISMATCH!>insideJob2()<!> }
suspend fun doTheJob2() = simpleAsync2 { <!ARGUMENT_TYPE_MISMATCH!><!NON_LOCAL_SUSPENSION_POINT!>insideJob2<!>()<!> }
suspend fun doTheJob3() = simpleAsync3 { <!ARGUMENT_TYPE_MISMATCH!>insideJob3()<!> }
@@ -1,39 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNCHECKED_CAST -UNUSED_LAMBDA_EXPRESSION
class Foo {
suspend operator fun <T> invoke(body: suspend (Int) -> T) = null as T
suspend fun <T> bar(body: suspend (Int) -> T) = null as T
}
fun <T> runBlocking(block: suspend () -> T) = null as T
public inline fun <T, R> T.run(block: T.() -> R) = null as R
fun main() {
val retry = Foo()
runBlocking {
retry { 1 } // OK only after fix
}
runBlocking {
retry { 1 } // OK
1
}
runBlocking {
retry.bar { 1 } // OK
}
runBlocking {
{ retry { 1 } } // should be error
}
runBlocking {
10.run { retry { 1 } } // should be OK
}
runBlocking {
10.run { retry { 1 } } // should be OK
1
}
runBlocking {
{ retry { 1 } } // should be error
1
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNCHECKED_CAST -UNUSED_LAMBDA_EXPRESSION
class Foo {