Files
kotlin-fork/backend.native/tests/external/codegen/box/objects/objectVsClassInitialization_kt5291.kt
T
2017-03-13 15:31:46 +03:00

25 lines
473 B
Kotlin

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