Mark implicit receiver as captured if the function is expression
#KT-40260 Fixed #KT-42280 Fixed
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user