mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
28 lines
576 B
Kotlin
Vendored
28 lines
576 B
Kotlin
Vendored
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
// WASM_MUTE_REASON: STDLIB_STRING_BUILDER
|
|
// KJS_WITH_FULL_RUNTIME
|
|
public inline fun <T> T.with(f: T.() -> Unit): T {
|
|
this.f()
|
|
return this
|
|
}
|
|
|
|
public class Cls {
|
|
val string = "Cls"
|
|
val buffer = StringBuilder().with {
|
|
append(string)
|
|
}
|
|
}
|
|
|
|
public object Obj {
|
|
val string = "Obj"
|
|
val buffer = StringBuilder().with {
|
|
append(string)
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
if (Cls().buffer.toString() != "Cls") return "Fail class"
|
|
if (Obj.buffer.toString() != "Obj") return "Fail object"
|
|
return "OK"
|
|
}
|