Add a test from KT-51950

This commit is contained in:
pyos
2022-04-28 16:52:54 +02:00
committed by Mikhael Bogdanov
parent 7bdc09301d
commit a1f0c6208c
13 changed files with 96 additions and 0 deletions
@@ -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")