Files
kotlin-fork/compiler/testData/codegen/boxInline/bytecodePreprocessing/inlineApiVersionAtLeastInStdlibInlineFunction.kt
T
vladislav.grechko e4f1c10bc1 [JVM_IR] Do not compile-time evaluate apiVersionIsAtLeast in stdlib
Function `apiVersionIsAtLeast` was introduced to be able to have
different inline function content inlined to user code call sites
depending on their api version settings. Thus, it should not be
compile-time evaluated when being called in the body of inline stdlib
function.

^KT-59452: Fixed
2023-06-19 16:24:57 +00:00

24 lines
600 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// Wrong function resolution after package renaming
// IGNORE_BACKEND: ANDROID
// WITH_STDLIB
// FILE: A.kt
package kotlin.internal
fun apiVersionIsAtLeast(epic: Int, major: Int, minor: Int): Boolean {
return false
}
inline fun versionDependentInlineFun() = if (apiVersionIsAtLeast(1, 1, 0)) "Fail" else "OK"
inline fun test() = versionDependentInlineFun()
// FILE: B.kt
import kotlin.internal.*
fun box(): String {
val clazz = Class.forName("kotlin.internal.AKt")
val func = clazz.methods.single { it.name == "test" }
return func.invoke(null) as String
}