Move changes from dfb379d under new language feature (#KT-28672)

Changes from that commit are breaking, and should be pass throw LC
This commit is contained in:
Dmitriy Novozhilov
2019-02-04 16:19:58 +03:00
parent cf25cab773
commit 9129210cfe
8 changed files with 68 additions and 4 deletions
@@ -20,7 +20,7 @@ fun smartcastOnReceiver(s: String?) {
<!UNSAFE_CALL!>length<!>
}
else {
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>length<!>
<!UNSAFE_CALL!>length<!>
}
}
}
@@ -0,0 +1,38 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect +ContractsOnCallsWithImplicitReceiver
// !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 {
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>length<!>
}
}
}
fun mixedReceiver(s: String?) {
if (!s.isNullOrEmpty()) {
with(<!DEBUG_INFO_SMARTCAST!>s<!>) {
length
}
} else {
with(s) {
<!UNSAFE_CALL!>length<!>
}
}
}
@@ -0,0 +1,6 @@
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