Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/useBeforeDeclaration.kt
T
2021-09-10 16:29:16 +03:00

22 lines
440 B
Kotlin
Vendored

// FIR_IDE_IGNORE
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
// !OPT_IN: kotlin.contracts.ExperimentalContracts
import kotlin.contracts.*
fun test(x: Any?) {
if (isString(x)) {
<!DEBUG_INFO_SMARTCAST!>x<!>.length
}
}
fun isString(x: Any?): Boolean {
contract {
returns(true) implies (x is String)
}
return x is String
}