Files
kotlin-fork/compiler/testData/codegen/box/defaultArguments/convention/incWithDefaultInGetter.kt
T
Ilya Chernikov 78ca733c38 FIR JS: add K2 variants of all other JS tests
except tests that are not possible to add without some modifications in
the test infra. See todos on the commented-out test declarations
2022-11-12 16:28:24 +01:00

28 lines
636 B
Kotlin
Vendored

// IGNORE_BACKEND_K2: JVM_IR, JS_IR
// FIR status: don't support legacy feature (prefix increment calls getter twice). fail 2: anone1
var inc: String = ""
class X {
var result: String = "fail"
operator fun get(name: String, type: String = "none") = name + inc + type
operator fun set(name: String, s: String) {
result = name + s;
}
}
operator fun String.inc(): String {
inc = this + "1"
return this + "1"
}
fun box(): String {
var x = X()
val res = ++x["a"]
if (x.result != "aanone1") return "fail 1: ${x.result}"
if (res != "aanone1none") return "fail 2: ${res}"
return "OK"
}