[Test] Add a test covering changes in the evaluation semantics of safe call with smart cast in K2
Addition to other safe call tests that are already present in tests. ^KT-41034
This commit is contained in:
committed by
Space Team
parent
12b3fbd39a
commit
aef6787e87
+6
@@ -28485,6 +28485,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
|||||||
public void testSafeCallOnFlexibleTypeAlias() throws Exception {
|
public void testSafeCallOnFlexibleTypeAlias() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallOnFlexibleTypeAlias.kt");
|
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallOnFlexibleTypeAlias.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("safeCallWithSmartCast.kt")
|
||||||
|
public void testSafeCallWithSmartCast() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallWithSmartCast.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+6
@@ -28485,6 +28485,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
|||||||
public void testSafeCallOnFlexibleTypeAlias() throws Exception {
|
public void testSafeCallOnFlexibleTypeAlias() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallOnFlexibleTypeAlias.kt");
|
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallOnFlexibleTypeAlias.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("safeCallWithSmartCast.kt")
|
||||||
|
public void testSafeCallWithSmartCast() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallWithSmartCast.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+6
@@ -28485,6 +28485,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
|||||||
public void testSafeCallOnFlexibleTypeAlias() throws Exception {
|
public void testSafeCallOnFlexibleTypeAlias() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallOnFlexibleTypeAlias.kt");
|
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallOnFlexibleTypeAlias.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("safeCallWithSmartCast.kt")
|
||||||
|
public void testSafeCallWithSmartCast() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallWithSmartCast.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+6
@@ -28497,6 +28497,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
|||||||
public void testSafeCallOnFlexibleTypeAlias() throws Exception {
|
public void testSafeCallOnFlexibleTypeAlias() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallOnFlexibleTypeAlias.kt");
|
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallOnFlexibleTypeAlias.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("safeCallWithSmartCast.kt")
|
||||||
|
public void testSafeCallWithSmartCast() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallWithSmartCast.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// WITH_STDLIB
|
||||||
|
|
||||||
|
class C {
|
||||||
|
var x: Int = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test(с: C?, a: Any) {
|
||||||
|
с?.x = if (a is String) 0 else throw Exception();
|
||||||
|
a.<!UNRESOLVED_REFERENCE!>toUpperCase<!>()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
test(null, 1)
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// WITH_STDLIB
|
||||||
|
|
||||||
|
class C {
|
||||||
|
var x: Int = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test(с: C?, a: Any) {
|
||||||
|
с?.x = if (a is String) 0 else throw Exception();
|
||||||
|
<!DEBUG_INFO_SMARTCAST!>a<!>.<!DEPRECATION!>toUpperCase<!>()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
test(null, 1)
|
||||||
|
}
|
||||||
Generated
+6
@@ -30111,6 +30111,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
public void testSafeCallOnFlexibleTypeAlias() throws Exception {
|
public void testSafeCallOnFlexibleTypeAlias() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallOnFlexibleTypeAlias.kt");
|
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallOnFlexibleTypeAlias.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("safeCallWithSmartCast.kt")
|
||||||
|
public void testSafeCallWithSmartCast() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallWithSmartCast.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
Reference in New Issue
Block a user