JVM, JVM IR: Don't optimize null-checks based on nullability information

Since Java interop allows us to circumvent the Kotlin type system we
cannot rely on nullability information.
This commit is contained in:
Steven Schäfer
2019-11-06 16:16:29 +01:00
committed by Alexander Udalov
parent de082543f1
commit b80e157381
6 changed files with 42 additions and 7 deletions
@@ -0,0 +1,18 @@
// TARGET_BACKEND: JVM
// FILE: Unsound.java
import test.Wrap;
public class Unsound {
public static <T> Wrap<T> get() {
return new Wrap<T>(null);
}
}
// FILE: 1.kt
package test
class Wrap<T>(val x: T)
fun box(): String = if ((Unsound.get<String>() as Wrap<String>).x == null) "OK" else "Fail"