Add testdata for issue #KT-28672

This commit is contained in:
Dmitriy Novozhilov
2019-01-14 11:33:20 +03:00
parent ba71bbde6a
commit 932e0234e7
4 changed files with 55 additions and 0 deletions
@@ -0,0 +1,38 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
//
// ISSUE: KT-28672
import kotlin.contracts.*
fun CharSequence?.isNullOrEmpty(): Boolean {
contract {
returns(false) implies (this@isNullOrEmpty != null)
}
return this == null || <!DEBUG_INFO_SMARTCAST!>this<!>.length == 0
}
fun smartcastOnReceiver(s: String?) {
with(s) {
if (isNullOrEmpty()) {
<!UNSAFE_CALL!>length<!>
}
else {
<!UNSAFE_CALL!>length<!>
}
}
}
fun mixedReceiver(s: String?) {
if (!s.isNullOrEmpty()) {
with(<!DEBUG_INFO_SMARTCAST!>s<!>) {
length
}
} else {
with(s) {
<!UNSAFE_CALL!>length<!>
}
}
}
@@ -0,0 +1,7 @@
package
public fun mixedReceiver(/*0*/ s: kotlin.String?): kotlin.Unit
public fun smartcastOnReceiver(/*0*/ s: kotlin.String?): kotlin.Unit
public fun kotlin.CharSequence?.isNullOrEmpty(): kotlin.Boolean
Returns(FALSE) -> <this> != null