[FIR] Create test case to validate KT-56988 is working as expected
^KT-56988 Fixed
This commit is contained in:
+6
@@ -47140,6 +47140,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/smartcasts/unsoundSmartcast.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/smartcasts/unsoundSmartcast.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("whileLoopNotNull.kt")
|
||||||
|
public void testWhileLoopNotNull() {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/smartcasts/whileLoopNotNull.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("withChangesToNull.kt")
|
@TestMetadata("withChangesToNull.kt")
|
||||||
public void testWithChangesToNull() {
|
public void testWithChangesToNull() {
|
||||||
|
|||||||
+6
@@ -47140,6 +47140,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/smartcasts/unsoundSmartcast.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/smartcasts/unsoundSmartcast.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("whileLoopNotNull.kt")
|
||||||
|
public void testWhileLoopNotNull() {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/smartcasts/whileLoopNotNull.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("withChangesToNull.kt")
|
@TestMetadata("withChangesToNull.kt")
|
||||||
public void testWithChangesToNull() {
|
public void testWithChangesToNull() {
|
||||||
|
|||||||
+6
@@ -44770,6 +44770,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/smartcasts/unsoundSmartcast.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/smartcasts/unsoundSmartcast.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("whileLoopNotNull.kt")
|
||||||
|
public void testWhileLoopNotNull() {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/smartcasts/whileLoopNotNull.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("withChangesToNull.kt")
|
@TestMetadata("withChangesToNull.kt")
|
||||||
public void testWithChangesToNull() {
|
public void testWithChangesToNull() {
|
||||||
|
|||||||
+6
@@ -44908,6 +44908,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/smartcasts/unsoundSmartcast.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/smartcasts/unsoundSmartcast.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("whileLoopNotNull.kt")
|
||||||
|
public void testWhileLoopNotNull() {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/smartcasts/whileLoopNotNull.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("withChangesToNull.kt")
|
@TestMetadata("withChangesToNull.kt")
|
||||||
public void testWithChangesToNull() {
|
public void testWithChangesToNull() {
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// FIR_DUMP
|
||||||
|
|
||||||
|
fun Int?.swap(): Int = 1
|
||||||
|
fun Int.swap(): Int? = null
|
||||||
|
|
||||||
|
var result = false
|
||||||
|
|
||||||
|
fun b(): Boolean {
|
||||||
|
result = !result
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
var x: Int? = 1
|
||||||
|
if (x != null) {
|
||||||
|
while (b()) {
|
||||||
|
val tmp = x.swap()
|
||||||
|
x = tmp
|
||||||
|
}
|
||||||
|
x.plus(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
FILE: whileLoopNotNull.fir.kt
|
||||||
|
public final fun R|kotlin/Int?|.swap(): R|kotlin/Int| {
|
||||||
|
^swap Int(1)
|
||||||
|
}
|
||||||
|
public final fun R|kotlin/Int|.swap(): R|kotlin/Int?| {
|
||||||
|
^swap Null(null)
|
||||||
|
}
|
||||||
|
public final var result: R|kotlin/Boolean| = Boolean(false)
|
||||||
|
public get(): R|kotlin/Boolean|
|
||||||
|
public set(value: R|kotlin/Boolean|): R|kotlin/Unit|
|
||||||
|
public final fun b(): R|kotlin/Boolean| {
|
||||||
|
R|/result| = R|/result|.R|kotlin/Boolean.not|()
|
||||||
|
^b R|/result|
|
||||||
|
}
|
||||||
|
public final fun test(): R|kotlin/Unit| {
|
||||||
|
lvar x: R|kotlin/Int?| = Int(1)
|
||||||
|
when () {
|
||||||
|
!=(R|<local>/x|, Null(null)) -> {
|
||||||
|
while(R|/b|()) {
|
||||||
|
lval tmp: R|kotlin/Int| = R|<local>/x|.R|/swap|()
|
||||||
|
R|<local>/x| = R|<local>/tmp|
|
||||||
|
}
|
||||||
|
|
||||||
|
R|<local>/x|.R|kotlin/Int.plus|(Int(1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// FIR_DUMP
|
||||||
|
|
||||||
|
fun Int?.swap(): Int = 1
|
||||||
|
fun Int.swap(): Int? = null
|
||||||
|
|
||||||
|
var result = false
|
||||||
|
|
||||||
|
fun b(): Boolean {
|
||||||
|
result = !result
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
var x: Int? = 1
|
||||||
|
if (x != null) {
|
||||||
|
while (b()) {
|
||||||
|
val tmp = x.swap()
|
||||||
|
x = tmp
|
||||||
|
}
|
||||||
|
x<!UNSAFE_CALL!>.<!>plus(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+6
@@ -47198,6 +47198,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/smartcasts/unsoundSmartcast.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/smartcasts/unsoundSmartcast.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("whileLoopNotNull.kt")
|
||||||
|
public void testWhileLoopNotNull() {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/smartcasts/whileLoopNotNull.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("withChangesToNull.kt")
|
@TestMetadata("withChangesToNull.kt")
|
||||||
public void testWithChangesToNull() {
|
public void testWithChangesToNull() {
|
||||||
|
|||||||
Reference in New Issue
Block a user