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
@@ -32,7 +32,7 @@ suspend fun calculate() = "OK"
fun box() {
builder {
test {
calculate()
<!NON_LOCAL_SUSPENSION_POINT!>calculate<!>()
}
}
}
@@ -32,7 +32,7 @@ suspend fun calculate() = "OK"
fun box() {
builder {
test {
calculate()
<!NON_LOCAL_SUSPENSION_POINT!>calculate<!>()
}
}
}
@@ -1,81 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
import Host.suspendFromObject
suspend fun suspendHere() = 1
suspend fun <T> another(a: T) = 1
object Host {
suspend fun suspendFromObject() = 1
}
fun <T> builder(c: suspend () -> Unit) { }
inline fun run(x: () -> Unit) {}
inline fun runCross(crossinline x: () -> Unit) {}
fun noinline(x: () -> Unit) {}
fun foo() {
var result = 1
builder<String> {
suspendHere()
suspendFromObject()
another("")
another(1)
result += suspendHere()
result += suspendFromObject()
run {
result += suspendHere()
result += suspendFromObject()
run {
suspendHere()
suspendFromObject()
}
}
runCross {
result += suspendHere()
result += suspendFromObject()
runCross {
suspendHere()
suspendFromObject()
}
}
noinline {
result += suspendHere()
result += suspendFromObject()
noinline {
suspendHere()
suspendFromObject()
}
}
class A {
fun bar() {
suspendHere()
suspendFromObject()
}
}
object : Any() {
fun baz() {
suspendHere()
suspendFromObject()
}
}
builder<Int> {
suspendHere()
suspendFromObject()
another(1)
another("")
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
import Host.suspendFromObject
@@ -6,10 +6,10 @@ suspend fun foo() = 1
suspend fun bar(
x: Int = 2 + foo(),
y: suspend () -> Int = { foo() },
z: () -> Int = { foo() },
z: () -> Int = { <!NON_LOCAL_SUSPENSION_POINT!>foo<!>() },
w: Int = myInline { foo() },
v: Any? = object {
fun x() = foo()
fun x() = <!NON_LOCAL_SUSPENSION_POINT!>foo<!>()
suspend fun y() = foo()
}
) {}