[Test] Add test for KT-62137

This commit is contained in:
Dmitriy Novozhilov
2023-11-06 10:16:22 +02:00
committed by Space Team
parent fd1c885c5b
commit c5d1c4e816
7 changed files with 66 additions and 0 deletions
@@ -38894,6 +38894,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/contracts"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("complexConditionWithSafeCall.kt")
public void testComplexConditionWithSafeCall() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/complexConditionWithSafeCall.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow")
@TestDataPath("$PROJECT_ROOT")
@@ -38894,6 +38894,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/contracts"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("complexConditionWithSafeCall.kt")
public void testComplexConditionWithSafeCall() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/complexConditionWithSafeCall.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow")
@TestDataPath("$PROJECT_ROOT")
@@ -38780,6 +38780,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/contracts"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("complexConditionWithSafeCall.kt")
public void testComplexConditionWithSafeCall() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/complexConditionWithSafeCall.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow")
@TestDataPath("$PROJECT_ROOT")
@@ -38894,6 +38894,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/contracts"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("complexConditionWithSafeCall.kt")
public void testComplexConditionWithSafeCall() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/complexConditionWithSafeCall.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow")
@TestDataPath("$PROJECT_ROOT")
@@ -0,0 +1,18 @@
// ISSUE: KT-62137
class PersonDto (
val name: String
)
fun test() {
val name: String? = null
val person: PersonDto? = null
if (!name.isNullOrEmpty()) {
name.length // Smart cast work
}
if (!person?.name.isNullOrEmpty()) {
person.name // Smart cast doesn't work
}
}
@@ -0,0 +1,18 @@
// ISSUE: KT-62137
class PersonDto (
val name: String
)
fun test() {
val name: String? = null
val person: PersonDto? = null
if (!name.isNullOrEmpty()) {
<!DEBUG_INFO_SMARTCAST!>name<!>.length // Smart cast work
}
if (!person?.name.isNullOrEmpty()) {
person<!UNSAFE_CALL!>.<!>name // Smart cast doesn't work
}
}
@@ -40834,6 +40834,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/contracts"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("complexConditionWithSafeCall.kt")
public void testComplexConditionWithSafeCall() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/complexConditionWithSafeCall.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow")
@TestDataPath("$PROJECT_ROOT")