[Test] Add test for KT-53460

This commit is contained in:
Dmitriy Novozhilov
2023-07-04 09:29:54 +03:00
committed by Space Team
parent 31d046e8cd
commit 5d6328a706
7 changed files with 58 additions and 0 deletions
@@ -22924,6 +22924,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/nullableTypes/kt58844.kt");
}
@Test
@TestMetadata("notUselessComparasionAfterSmartcast.kt")
public void testNotUselessComparasionAfterSmartcast() throws Exception {
runTest("compiler/testData/diagnostics/tests/nullableTypes/notUselessComparasionAfterSmartcast.kt");
}
@Test
@TestMetadata("nullAssertOnTypeWithNullableUpperBound.kt")
public void testNullAssertOnTypeWithNullableUpperBound() throws Exception {
@@ -22924,6 +22924,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/nullableTypes/kt58844.kt");
}
@Test
@TestMetadata("notUselessComparasionAfterSmartcast.kt")
public void testNotUselessComparasionAfterSmartcast() throws Exception {
runTest("compiler/testData/diagnostics/tests/nullableTypes/notUselessComparasionAfterSmartcast.kt");
}
@Test
@TestMetadata("nullAssertOnTypeWithNullableUpperBound.kt")
public void testNullAssertOnTypeWithNullableUpperBound() throws Exception {
@@ -22924,6 +22924,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/nullableTypes/kt58844.kt");
}
@Test
@TestMetadata("notUselessComparasionAfterSmartcast.kt")
public void testNotUselessComparasionAfterSmartcast() throws Exception {
runTest("compiler/testData/diagnostics/tests/nullableTypes/notUselessComparasionAfterSmartcast.kt");
}
@Test
@TestMetadata("nullAssertOnTypeWithNullableUpperBound.kt")
public void testNullAssertOnTypeWithNullableUpperBound() throws Exception {
@@ -22930,6 +22930,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/nullableTypes/kt58844.kt");
}
@Test
@TestMetadata("notUselessComparasionAfterSmartcast.kt")
public void testNotUselessComparasionAfterSmartcast() throws Exception {
runTest("compiler/testData/diagnostics/tests/nullableTypes/notUselessComparasionAfterSmartcast.kt");
}
@Test
@TestMetadata("nullAssertOnTypeWithNullableUpperBound.kt")
public void testNullAssertOnTypeWithNullableUpperBound() throws Exception {
@@ -0,0 +1,14 @@
// ISSUE: KT-53460
fun test(a: String?, b: String?) {
if (a == null || a == "foo") {
when (b) {
"abc" -> return
}
}
a<!UNSAFE_CALL!>.<!>length // should be an error
if (a == null || a == "bar") { // comparasion to null is not useless
a<!UNSAFE_CALL!>.<!>length
}
}
@@ -0,0 +1,14 @@
// ISSUE: KT-53460
fun test(a: String?, b: String?) {
if (a == null || a == "foo") {
when (b) {
"abc" -> return
}
}
<!DEBUG_INFO_SMARTCAST!>a<!>.length // should be an error
if (<!SENSELESS_COMPARISON!>a == null<!> || a == "bar") { // comparasion to null is not useless
<!DEBUG_INFO_SMARTCAST!>a<!>.length
}
}
@@ -23762,6 +23762,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/nullableTypes/kt58844.kt");
}
@Test
@TestMetadata("notUselessComparasionAfterSmartcast.kt")
public void testNotUselessComparasionAfterSmartcast() throws Exception {
runTest("compiler/testData/diagnostics/tests/nullableTypes/notUselessComparasionAfterSmartcast.kt");
}
@Test
@TestMetadata("nullAssertOnTypeWithNullableUpperBound.kt")
public void testNullAssertOnTypeWithNullableUpperBound() throws Exception {