JVM_IR: check for null when converting unboxed inline classes to strings
`C?` can be unboxed into `T?` if if wraps a reference type `T!!`, but in this case `null` is not a valid value to pass to `toString-impl`. #KT-42005 Fixed
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
inline class IC(val x: String)
|
||||
|
||||
fun IC?.foo() = toString() // `IC?` unboxed into `String?`
|
||||
fun IC?.bar() = "$this"
|
||||
|
||||
fun assertEquals(a: String, b: String) {
|
||||
if (a != b) throw AssertionError("$a != $b")
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals((null as IC?).foo(), "null")
|
||||
assertEquals((null as IC?).foo(), (null as IC?).toString())
|
||||
assertEquals((null as IC?).foo(), (null as IC?).bar())
|
||||
assertEquals(IC("x").foo(), "IC(x=x)")
|
||||
assertEquals(IC("x").foo(), IC("x").toString())
|
||||
assertEquals(IC("x").foo(), IC("x").bar())
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user