Add test on isNullOrEmpty-like contract

Currently, behavior is undesired, see KT-27241
This commit is contained in:
Dmitry Savvinov
2018-10-17 15:09:05 +03:00
parent 48d832298b
commit 04ff2a3ee7
4 changed files with 25 additions and 0 deletions
@@ -0,0 +1,11 @@
// !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<!>) {
<!DEBUG_INFO_SMARTCAST!>value<!>.length
}
}
@@ -0,0 +1,4 @@
package
public fun myIf(/*0*/ cond: kotlin.Boolean): kotlin.Any
public fun test(/*0*/ x: kotlin.Any?): kotlin.Unit
@@ -1341,6 +1341,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/unreachableBranches.kt");
}
@TestMetadata("valueOfContractedFunctionIngored.kt")
public void testValueOfContractedFunctionIngored() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/valueOfContractedFunctionIngored.kt");
}
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/multieffect")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1341,6 +1341,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/unreachableBranches.kt");
}
@TestMetadata("valueOfContractedFunctionIngored.kt")
public void testValueOfContractedFunctionIngored() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/valueOfContractedFunctionIngored.kt");
}
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/multieffect")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)