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
@@ -1296,6 +1296,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/deeplyNested.kt");
}
@TestMetadata("extensionReceiver.kt")
public void testExtensionReceiver() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/extensionReceiver.kt");
}
@TestMetadata("intersectingInfo.kt")
public void testIntersectingInfo() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectingInfo.kt");
@@ -1296,6 +1296,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/deeplyNested.kt");
}
@TestMetadata("extensionReceiver.kt")
public void testExtensionReceiver() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/extensionReceiver.kt");
}
@TestMetadata("intersectingInfo.kt")
public void testIntersectingInfo() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectingInfo.kt");