e483f83666
Consider following expression: 'call() is Foo'. Suppose that we know something about the 'call()', e.g. 'returns(foo) -> <condition>' Previously, we've tried to re-use knowledge about 'call()', constructing some smart clause, like 'returns(true) -> foo is Foo && <condition>'. The conceptual error here is that *we can't* argue that <condition> holds. Imagine that 'call()' actually has unspecified 'returns(foo2) -> <!condition>', and 'foo2 is Foo' also holds. Then we would get 'returns(true) -> foo2 is Foo && <condition>' <=> 'returns(true) -> <condition>' for the whole call, which is not correct. More concrete example would be something like: 'if (!x.isNullOrEmpty() is Boolean)' ^KT-27241 Fixed
11 lines
350 B
Kotlin
Vendored
11 lines
350 B
Kotlin
Vendored
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect
|
|
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
|
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
|
|
|
|
import kotlin.contracts.*
|
|
|
|
fun f3(value: String?) {
|
|
if (<!USELESS_IS_CHECK!>!value.isNullOrEmpty() is Boolean<!>) {
|
|
value<!UNSAFE_CALL!>.<!>length
|
|
}
|
|
} |