Files
kotlin/compiler/testData/codegen/box/inlineClasses/toStringOfUnboxedNullable.kt
Denis Zharkov f97cc0b62d FIR: Rework receivers processing in resolution
- Put extensionReceiver to candidate even if it's explicit (for sake of clarity)
- Split CheckReceiver (dispatch part should only check nullability)
2020-11-16 15:50:39 +03:00

22 lines
635 B
Kotlin
Vendored

// !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"
}