Add testdata for issue #KT-28672
This commit is contained in:
+38
@@ -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<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -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
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java
Generated
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user