Add test on in-place lambda with return + safecall

Currently, diagnostics behavior is undesired. The next commit fixes it

^KT-28061 In Progress
This commit is contained in:
Dmitry Savvinov
2018-11-12 15:19:24 +03:00
parent b918786336
commit c9e87bf353
9 changed files with 218 additions and 0 deletions
@@ -0,0 +1,17 @@
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
import kotlin.contracts.*
inline fun Any?.myRun(block: () -> Unit): Unit {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return block()
}
fun test(): String {
val x: String? = null
x?.myRun { return "" }
}
@@ -0,0 +1,6 @@
package
public fun test(): kotlin.String
public inline fun kotlin.Any?.myRun(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, EXACTLY_ONCE)