a5c8e30bb1
If inline function A calls another inline function B, we must use the original version of inline function A for inlining, which doesn’t have inlined function B. Because during the inlining process, we remap all occurrences of inline function A to a temporary copy of function A, and if the function B somehow uses function A (e.g. callable reference), the built IR will have a reference to the temporary function, not the original one. All these things lead to broken cross-module references. This patch saves the original versions of all inline functions before inlining and provides them during the inline process. ^KT-55930 Fixed
25 lines
384 B
Kotlin
Vendored
25 lines
384 B
Kotlin
Vendored
// IGNORE_BACKEND: JS
|
|
// MODULE: lib
|
|
// FILE: A.kt
|
|
inline fun funA(flag: Boolean): String {
|
|
if (flag) {
|
|
return funB(flag)
|
|
}
|
|
return "OK"
|
|
}
|
|
|
|
// FILE: B.kt
|
|
inline fun funB(flag: Boolean): String {
|
|
val f = ::funA
|
|
if (flag) {
|
|
return f(false)
|
|
}
|
|
return "NOT OK"
|
|
}
|
|
|
|
// MODULE: main(lib)
|
|
// FILE: main.kt
|
|
fun box(): String {
|
|
return funA(true)
|
|
}
|