Mark implicit receiver as captured if the function is expression

#KT-40260 Fixed
 #KT-42280 Fixed
This commit is contained in:
Ilmir Usmanov
2020-09-30 21:00:26 +02:00
parent 3078bd7b67
commit 5e02a4efd7
10 changed files with 141 additions and 1 deletions
@@ -0,0 +1,35 @@
// WITH_RUNTIME
// WITH_COROUTINES
import helpers.*
import kotlin.coroutines.*
fun builder(c: suspend Context.() -> Unit) {
c.startCoroutine(Context(), EmptyContinuation)
}
class Foo {
fun foo() {
val fionaClient = Any()
coVerify { fionaClient was Called }
}
}
object Called
var res = "FAIL"
class Context {
infix fun Any.was(called: Called) {
res = "OK"
}
}
fun coVerify(verifyBlock: suspend Context.() -> Unit) {
builder(verifyBlock)
}
fun box(): String {
Foo().foo()
return res
}
@@ -0,0 +1,33 @@
// WITH_RUNTIME
// WITH_COROUTINES
import helpers.*
import kotlin.coroutines.*
fun builder(c: suspend Context.() -> Unit) {
c.startCoroutine(Context(), EmptyContinuation)
}
class Foo {
fun foo() {
val fionaClient = Any()
coVerify { !fionaClient }
}
}
var res = "FAIL"
class Context {
operator fun Any.not() {
res = "OK"
}
}
fun coVerify(verifyBlock: suspend Context.() -> Unit) {
builder(verifyBlock)
}
fun box(): String {
Foo().foo()
return res
}