b2041e0927
There are many complications with the current design of passing data from within in-place lambdas to surrounding code. Solving these complications will involve more time to investigation than is available within the K2 release. So we are disabling passing type statement information from lambdas for the time being until more time can be devoted to a more complete solution. ^KT-60958 Fixed ^KT-63530 Fixed
49 lines
1014 B
Kotlin
Vendored
49 lines
1014 B
Kotlin
Vendored
// FIR_IDENTICAL
|
|
// LANGUAGE: +ReadDeserializedContracts +UseReturnsEffect
|
|
// DIAGNOSTICS: -INVISIBLE_REFERENCE, -INVISIBLE_MEMBER, -DEBUG_INFO_SMARTCAST
|
|
// SKIP_TXT
|
|
|
|
fun testRequireSmartcast(x: Any?) {
|
|
require(x is String)
|
|
x.length
|
|
}
|
|
|
|
fun testRequireUnreachableCode() {
|
|
require(false)
|
|
println("Can't get here!")
|
|
}
|
|
|
|
fun testRequireWithMessage(x: Any?) {
|
|
require(x is String) { "x is not String!" }
|
|
x.length
|
|
}
|
|
|
|
fun testRequireWithFailingMessage(x: Any?) {
|
|
require(x is String) { throw kotlin.IllegalStateException("What a strange idea") }
|
|
x.length
|
|
}
|
|
|
|
fun tesRequireNotNullWithMessage(x: Int?) {
|
|
requireNotNull(x) { "x is null!"}
|
|
x.inc()
|
|
}
|
|
|
|
fun testRequireAndDefiniteReturn(x: Any, b: Boolean) {
|
|
if (b) {
|
|
require(x is String)
|
|
} else {
|
|
return
|
|
}
|
|
x.length
|
|
}
|
|
|
|
|
|
fun testRequireWithFailingMessageAndDefiniteReturn(x: Any, b: Boolean) {
|
|
if (b) {
|
|
require(x is String) { "x is not String!" }
|
|
} else {
|
|
return
|
|
}
|
|
x.length
|
|
}
|