[Test] Add test for KT-55338
This commit is contained in:
committed by
teamcity
parent
a3768b9185
commit
44fd9ddf85
+6
@@ -30669,6 +30669,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/capturedByNested.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedLoopVariable.kt")
|
||||
public void testCapturedLoopVariable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/capturedLoopVariable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedWithControlJumps.kt")
|
||||
public void testCapturedWithControlJumps() throws Exception {
|
||||
|
||||
+6
@@ -30765,6 +30765,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/capturedByNested.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedLoopVariable.kt")
|
||||
public void testCapturedLoopVariable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/capturedLoopVariable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedWithControlJumps.kt")
|
||||
public void testCapturedWithControlJumps() throws Exception {
|
||||
|
||||
+6
@@ -30669,6 +30669,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/capturedByNested.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedLoopVariable.kt")
|
||||
public void testCapturedLoopVariable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/capturedLoopVariable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedWithControlJumps.kt")
|
||||
public void testCapturedWithControlJumps() throws Exception {
|
||||
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
// ISSUE: KT-55338
|
||||
|
||||
fun test_1() {
|
||||
var s: String? = null
|
||||
|
||||
for (i in 1..10) {
|
||||
if (s == null) {
|
||||
s = "hello"
|
||||
}
|
||||
s.length // smartcast in K1 and K2
|
||||
noInlineRun { <!SMARTCAST_IMPOSSIBLE!>s<!>.length } // smartcast in K1, unsafe call in K2 <------------
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2_1() {
|
||||
var s: String? = null
|
||||
|
||||
for (i in 1..10) {
|
||||
if (s == null) {
|
||||
s = "hello"
|
||||
}
|
||||
s.length // smartcast in K1 and K2
|
||||
noInlineRun { <!SMARTCAST_IMPOSSIBLE!>s<!>.length } // unsafe call in K1 and K2
|
||||
s = ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2_2() {
|
||||
var s: String? = null
|
||||
|
||||
for (i in 1..10) {
|
||||
if (s == null) {
|
||||
s = "hello"
|
||||
}
|
||||
s.length // smartcast in K1 and K2
|
||||
noInlineRun { <!SMARTCAST_IMPOSSIBLE!>s<!>.length } // unsafe call in K1 and K2
|
||||
s = null
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3_1() {
|
||||
var s: String? = null
|
||||
|
||||
for (i in 1..10) {
|
||||
if (s == null) {
|
||||
s = "hello"
|
||||
} else {
|
||||
s = null
|
||||
}
|
||||
s<!UNSAFE_CALL!>.<!>length // unsafe call in K1 and K2
|
||||
noInlineRun { s<!UNSAFE_CALL!>.<!>length } // unsafe call in K1 and K2
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3_2() {
|
||||
var s: String? = null
|
||||
|
||||
for (i in 1..10) {
|
||||
if (s == null) {
|
||||
s = "hello"
|
||||
} else {
|
||||
s = "world"
|
||||
}
|
||||
s.length // smartcast in K1 and K2
|
||||
noInlineRun { <!SMARTCAST_IMPOSSIBLE!>s<!>.length } // smartcast in K1, unsafe call in K2 <------------
|
||||
}
|
||||
}
|
||||
|
||||
fun test_4_1() {
|
||||
var s: String? = null
|
||||
|
||||
for (i in 1..10) {
|
||||
if (s == null) {
|
||||
s = getString()
|
||||
} else {
|
||||
s = getNullableString()
|
||||
}
|
||||
s<!UNSAFE_CALL!>.<!>length // unsafe call in K1 and K2
|
||||
noInlineRun { s<!UNSAFE_CALL!>.<!>length } // unsafe call in K1 and K2
|
||||
}
|
||||
}
|
||||
|
||||
fun test_4_2() {
|
||||
var s: String? = null
|
||||
|
||||
for (i in 1..10) {
|
||||
if (s == null) {
|
||||
s = getString()
|
||||
} else {
|
||||
s = getString()
|
||||
}
|
||||
s.length // smartcast in K1 and K2
|
||||
noInlineRun { <!SMARTCAST_IMPOSSIBLE!>s<!>.length } // smartcast in K1, unsafe call in K2 <------------
|
||||
}
|
||||
}
|
||||
|
||||
fun getNullableString(): String? = null
|
||||
fun getString(): String = "hello"
|
||||
fun noInlineRun(block: () -> Unit) {}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
// ISSUE: KT-55338
|
||||
|
||||
fun test_1() {
|
||||
var s: String? = null
|
||||
|
||||
for (i in 1..10) {
|
||||
if (s == null) {
|
||||
s = "hello"
|
||||
}
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length // smartcast in K1 and K2
|
||||
noInlineRun { <!DEBUG_INFO_SMARTCAST!>s<!>.length } // smartcast in K1, unsafe call in K2 <------------
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2_1() {
|
||||
var s: String? = null
|
||||
|
||||
for (i in 1..10) {
|
||||
if (s == null) {
|
||||
s = "hello"
|
||||
}
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length // smartcast in K1 and K2
|
||||
noInlineRun { <!SMARTCAST_IMPOSSIBLE!>s<!>.length } // unsafe call in K1 and K2
|
||||
s = ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2_2() {
|
||||
var s: String? = null
|
||||
|
||||
for (i in 1..10) {
|
||||
if (s == null) {
|
||||
s = "hello"
|
||||
}
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length // smartcast in K1 and K2
|
||||
noInlineRun { <!SMARTCAST_IMPOSSIBLE!>s<!>.length } // unsafe call in K1 and K2
|
||||
s = null
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3_1() {
|
||||
var s: String? = null
|
||||
|
||||
for (i in 1..10) {
|
||||
if (s == null) {
|
||||
s = "hello"
|
||||
} else {
|
||||
s = null
|
||||
}
|
||||
s<!UNSAFE_CALL!>.<!>length // unsafe call in K1 and K2
|
||||
noInlineRun { s<!UNSAFE_CALL!>.<!>length } // unsafe call in K1 and K2
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3_2() {
|
||||
var s: String? = null
|
||||
|
||||
for (i in 1..10) {
|
||||
if (s == null) {
|
||||
s = "hello"
|
||||
} else {
|
||||
s = "world"
|
||||
}
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length // smartcast in K1 and K2
|
||||
noInlineRun { <!DEBUG_INFO_SMARTCAST!>s<!>.length } // smartcast in K1, unsafe call in K2 <------------
|
||||
}
|
||||
}
|
||||
|
||||
fun test_4_1() {
|
||||
var s: String? = null
|
||||
|
||||
for (i in 1..10) {
|
||||
if (s == null) {
|
||||
s = getString()
|
||||
} else {
|
||||
s = getNullableString()
|
||||
}
|
||||
s<!UNSAFE_CALL!>.<!>length // unsafe call in K1 and K2
|
||||
noInlineRun { s<!UNSAFE_CALL!>.<!>length } // unsafe call in K1 and K2
|
||||
}
|
||||
}
|
||||
|
||||
fun test_4_2() {
|
||||
var s: String? = null
|
||||
|
||||
for (i in 1..10) {
|
||||
if (s == null) {
|
||||
s = getString()
|
||||
} else {
|
||||
s = getString()
|
||||
}
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length // smartcast in K1 and K2
|
||||
noInlineRun { <!DEBUG_INFO_SMARTCAST!>s<!>.length } // smartcast in K1, unsafe call in K2 <------------
|
||||
}
|
||||
}
|
||||
|
||||
fun getNullableString(): String? = null
|
||||
fun getString(): String = "hello"
|
||||
fun noInlineRun(block: () -> Unit) {}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package
|
||||
|
||||
public fun getNullableString(): kotlin.String?
|
||||
public fun getString(): kotlin.String
|
||||
public fun noInlineRun(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
|
||||
public fun test_1(): kotlin.Unit
|
||||
public fun test_2_1(): kotlin.Unit
|
||||
public fun test_2_2(): kotlin.Unit
|
||||
public fun test_3_1(): kotlin.Unit
|
||||
public fun test_3_2(): kotlin.Unit
|
||||
public fun test_4_1(): kotlin.Unit
|
||||
public fun test_4_2(): kotlin.Unit
|
||||
Generated
+6
@@ -30765,6 +30765,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/capturedByNested.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedLoopVariable.kt")
|
||||
public void testCapturedLoopVariable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/capturedLoopVariable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedWithControlJumps.kt")
|
||||
public void testCapturedWithControlJumps() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user