[BE JVM] KT-51271 Set proper indices generating contextual inline call

[Tests] Test inline call with context receivers and default params
This commit is contained in:
Anastasia.Shadrina
2022-02-18 02:48:05 +07:00
committed by teamcity
parent dc210fa6ef
commit 4b366ddcf6
14 changed files with 338 additions and 7 deletions
@@ -0,0 +1,39 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
// FIR status: context receivers aren't yet supported
// KT-51271
class Context {
fun c() = 1
}
context(Context)
inline fun testInline() = c()
context(Context)
inline fun testInlineWithArg(i: Int) = i + c()
context(Context)
inline fun Int.testInlineWithExtensionAndArg(i: Int) = this@Int + i + c()
context(Context)
inline fun Int.testInlineWithExtensionAndMultipleArgs(i1: Int, i2: Int) = this@Int + i1 + i2 + c()
context(Context, Any)
inline fun Int.testInlineWithExtensionAndMultipleContextsAndArgs(i1: Int = 1, i2: Int = 2) =
this@Int + i1 + i2 + c() + if (this@Any == null) 0 else 1
fun box(): String = with(Context()) {
var result = 0
result += testInline()
result += testInlineWithArg(1)
result += 1.testInlineWithExtensionAndArg(1)
result += 1.testInlineWithExtensionAndMultipleArgs(1, 2)
with(1) {
result += 1.testInlineWithExtensionAndMultipleContextsAndArgs(1, 2)
result += 1.testInlineWithExtensionAndMultipleContextsAndArgs()
}
return if (result == 23) "OK" else "fail"
}