Files
kotlin-fork/compiler/testData/codegen/box/extensionClasses/constructors.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

34 lines
749 B
Kotlin
Vendored

// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
// FIR status: context receivers aren't yet supported
// WITH_STDLIB
class A(val ok: String)
context(A)
class B(oValue: Boolean = true, kValue: Boolean = true) {
var o: Boolean
var k: Boolean
init {
o = oValue
k = kValue
}
constructor(oValue: String, kValue: String) : this(oValue == "O", kValue == "K")
fun result() = if (o && k) ok else "fail"
}
fun box(): String {
val a = A("OK")
with (a) {
val results = listOf(
B(true, true).result(),
B("O", "K").result(),
B().result()
)
return if (results.all { it == "OK" }) "OK" else "fail"
}
}