281f09f077
There is a trade-off between robustness of check and accuracy of the diagnostic: the previous version, which works on generation, was too fragile and lead to false-positives. Now we check on state machine generation. However, since we do not have PSI for call, we can only report diagnostic on whole suspend function or suspend lambda. Additionally, the state machine is generated on crossinline suspend lambdas regeneration and thus we do not have the PSI for the lambda as well! #KT-27130 Fixed #KT-27258 Open
53 lines
865 B
Kotlin
Vendored
53 lines
865 B
Kotlin
Vendored
fun builder(c: suspend () -> Unit) {}
|
|
|
|
private val lock = Any()
|
|
|
|
suspend fun suspensionPoint() {}
|
|
|
|
fun test() {
|
|
builder {
|
|
synchronized(lock) {
|
|
suspensionPoint()
|
|
}
|
|
}
|
|
|
|
builder {
|
|
inlineMe {
|
|
suspensionPoint()
|
|
}
|
|
}
|
|
|
|
builder {
|
|
monitorInFinally(
|
|
{},
|
|
{ suspensionPoint() }
|
|
)
|
|
}
|
|
|
|
synchronized(lock) {
|
|
builder {
|
|
suspensionPoint()
|
|
}
|
|
}
|
|
|
|
synchronized(lock) {
|
|
object : SuspendRunnable {
|
|
override suspend fun run() {
|
|
suspensionPoint()
|
|
}
|
|
}
|
|
}
|
|
|
|
object : SuspendRunnable {
|
|
override suspend fun run() {
|
|
synchronized(lock) {
|
|
suspensionPoint()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
interface SuspendRunnable {
|
|
suspend fun run()
|
|
}
|