166c771e1b
If we want to analyse some function's call, we need to know about its contracts, otherwise resolving the following code would be broken. Computing return type of function is a prerequisite to using it in any sensible way, so it's the best place to resolve it to CONTRACTS KT-50733
21 lines
422 B
Kotlin
Vendored
21 lines
422 B
Kotlin
Vendored
// !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
|
|
}
|
|
|
|
|