Add test on smartcast from while-assigned var
Currently behavior is undesired, it will be fixed in the next commit (see KT-27084)
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
fun main(args: Array<String>) {
|
||||
var result: String? = null
|
||||
var i = 0
|
||||
while (result == null) {
|
||||
if (i == 10) result = "non null"
|
||||
else i++
|
||||
}
|
||||
result<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
public fun main(/*0*/ args: kotlin.Array<kotlin.String>): kotlin.Unit
|
||||
@@ -19916,6 +19916,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/loops/whileNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("whileNullAssignToSomething.kt")
|
||||
public void testWhileNullAssignToSomething() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/loops/whileNullAssignToSomething.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("whileNullWithBreak.kt")
|
||||
public void testWhileNullWithBreak() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/loops/whileNullWithBreak.kt");
|
||||
|
||||
Generated
+5
@@ -19916,6 +19916,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/loops/whileNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("whileNullAssignToSomething.kt")
|
||||
public void testWhileNullAssignToSomething() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/loops/whileNullAssignToSomething.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("whileNullWithBreak.kt")
|
||||
public void testWhileNullWithBreak() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/loops/whileNullWithBreak.kt");
|
||||
|
||||
Reference in New Issue
Block a user