IR: Don't use IrStringConcatenation for ordinary toString calls

We can only use IrStrinConcatentation to represent calls to Any?.toString
and toString calls on primitive types. Otherwise, x.toString() and "$x"
are observably different when x is a non-null type with null value
(e.g., an @NotNull value coming from Java).
This commit is contained in:
Steven Schäfer
2020-03-26 13:15:24 +01:00
committed by Dmitry Petrov
parent c1b9fdd2f3
commit 58685be4e2
9 changed files with 73 additions and 8 deletions
@@ -0,0 +1,22 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FILE: J.java
import org.jetbrains.annotations.NotNull;
public class J {
@NotNull
public static String notNullStringIsNull() {
return null;
}
}
// FILE: test.kt
fun box(): String {
try {
J.notNullStringIsNull().toString()
} catch (e: java.lang.NullPointerException) {
return "OK"
}
return "Fail"
}