[FIR2IR] Fix and refactor generation of dynamic call receiver generation

#KT-57988 Fixed
This commit is contained in:
Kirill Rakhman
2023-04-18 15:58:03 +02:00
committed by Space Team
parent 8b47a4fa48
commit 35c6da1aa7
7 changed files with 99 additions and 26 deletions
@@ -0,0 +1,25 @@
FILE: getOperatorOnDynamicThis.kt
public final inline fun <T : R|kotlin/Any|> jso(): R|T| {
^jso R|kotlin/js/js|(String(({})))
}
public final inline fun <T : R|kotlin/Any|> jso(block: R|T.() -> kotlin/Unit|): R|T| {
^jso R|/jso|<R|T|>().R|kotlin/apply|<R|T|>(R|<local>/block|)
}
public abstract external interface Z : R|kotlin/Any| {
public abstract var a: R|dynamic|
public get(): R|dynamic|
public set(value: R|dynamic|): R|kotlin/Unit|
}
public final fun foo(): R|kotlin/Unit| {
R|/jso|<R|Z|>().R|kotlin/apply|<R|Z|>(<L> = apply@fun R|Z|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
this@R|special/anonymous|.R|/Z.a| = R|/jso|<R|dynamic|>(<L> = jso@fun R|dynamic|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
this@R|special/anonymous|.R|<dynamic>/get|(vararg(this@R|special/anonymous|.R|<dynamic>/foo|.R|<dynamic>/bar|))
}
)
}
)
}
public final fun box(): R|kotlin/String| {
^box String(OK)
}
@@ -0,0 +1,20 @@
// TARGET_BACKEND: JS
// ISSUE: KT-57988
// FIR_DUMP
inline fun <T : Any> jso(): T = js("({})")
inline fun <T : Any> jso(block: T.() -> Unit): T = jso<T>().apply(block)
external interface Z {
var a: dynamic
}
fun foo() {
jso<Z>().apply {
a = jso {
this[foo.bar]
}
}
}
fun box() = "OK"