Add a test from KT-51950
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// FILE: 1.kt
|
||||
interface Service {
|
||||
fun send(message: String): String
|
||||
}
|
||||
|
||||
inline fun Service.decorate(crossinline decorate: (Service) -> Service): Service =
|
||||
object : Service by decorate(this) {}
|
||||
|
||||
inline fun Service.transformMessage(crossinline transform: (String) -> String) =
|
||||
decorate { service ->
|
||||
object : Service {
|
||||
override fun send(message: String): String =
|
||||
service.send(transform(message))
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
fun Service.append(suffix: String): Service =
|
||||
transformMessage { it + suffix }
|
||||
|
||||
fun box(): String =
|
||||
object : Service {
|
||||
override fun send(message: String): String = message
|
||||
}.append("K").send("O")
|
||||
Reference in New Issue
Block a user