mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-04-23 15:52:40 +00:00
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).
23 lines
394 B
Kotlin
Vendored
23 lines
394 B
Kotlin
Vendored
// 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"
|
|
}
|