Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/useBeforeDeclaration.fir.kt
T
2020-04-15 11:13:01 +03:00

21 lines
405 B
Kotlin
Vendored

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