FIR: Load final static constant Java fields as non-nullable

This commit is contained in:
Denis.Zharkov
2021-11-17 19:44:31 +03:00
committed by teamcityserver
parent dba04bcf80
commit 46217318c0
14 changed files with 113 additions and 24 deletions
@@ -0,0 +1,27 @@
// SKIP_TXT
// FILE: JavaClass.java
public class JavaClass {
public final static String X = "";
public final static String Y = "";
}
// FILE: main.kt
fun nullableStr(): String? = null
fun foo(w: Int): String {
var x: String? = nullableStr()
if (x != null) {
return x
}
// Smartcast should work because when's entries' results are non-flexible
x = nullableStr() ?: when (w) {
1 -> JavaClass.X
else -> JavaClass.Y
}
return x
}
@@ -0,0 +1,27 @@
// SKIP_TXT
// FILE: JavaClass.java
public class JavaClass {
public final static String X = "";
public final static String Y = "";
}
// FILE: main.kt
fun nullableStr(): String? = null
fun foo(w: Int): String {
var x: String? = nullableStr()
if (x != null) {
return <!DEBUG_INFO_SMARTCAST!>x<!>
}
// Smartcast should work because when's entries' results are non-flexible
x = nullableStr() ?: when (w) {
1 -> JavaClass.X
else -> JavaClass.Y
}
return <!DEBUG_INFO_SMARTCAST!>x<!>
}