Files
kotlin-fork/compiler/testData/codegen/boxInline/optimizations/kt20844.kt
T
2018-08-02 13:19:24 +02:00

27 lines
579 B
Kotlin
Vendored

// FILE: 1.kt
//WITH_RUNTIME
package test
data class Address(
val createdTimeMs: Long = 0,
val firstName: String = "",
val lastName: String = ""
)
inline fun String.switchIfEmpty(provider: () -> String): String {
return if (isEmpty()) provider() else this
}
// FILE: 2.kt
import test.*
fun box(): String {
val address = Address()
val result = address.copy(
firstName = address.firstName.switchIfEmpty { "O" },
lastName = address.lastName.switchIfEmpty { "K" }
)
return result.firstName + result.lastName
}