Files
kotlin-fork/compiler/testData/codegen/boxInline/bytecodePreprocessing/apiVersionAtLeast1.kt
T
vladislav.grechko 38e9dfc823 Evaluate apiVersionIsAtLeast on compile time while IR-inlining
IR inliner should evaluate `apiVersionIsAtLeast` on compile-time (except
cases of inlining to inline functions from kotlin runtime) just as
bytecode inliner does.

^KT-59291: Fixed
2023-06-22 11:55:04 +00:00

46 lines
749 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// Wrong function resolution after package renaming
// IGNORE_BACKEND: ANDROID
// FILE: 1.kt
package kotlin.internal
fun apiVersionIsAtLeast(epic: Int, major: Int, minor: Int): Boolean {
return false
}
var properFunctionWasClled = false
fun doSomethingNew() {
properFunctionWasClled = true
}
fun doSomethingOld() {
throw AssertionError("Should not be called")
}
inline fun versionDependentInlineFun() {
if (apiVersionIsAtLeast(1, 1, 0)) {
doSomethingNew()
}
else {
doSomethingOld()
}
}
fun test() {
versionDependentInlineFun()
}
// FILE: 2.kt
import kotlin.internal.*
fun box(): String {
test()
if (!properFunctionWasClled) return "Fail 1"
return "OK"
}