Files
kotlin-fork/compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/kCallableName.kt
T
Ivan Kylchik 8067df3c94 [IR] Combine IrInterpreterNameCheck with common one
This way we achieve faster compilation time. We want to traverse
IR tree as little as possible. If we add new checker than the time
to evaluate constants basically doubles.

#KT-58923
2023-06-14 19:02:39 +00:00

31 lines
1.2 KiB
Kotlin
Vendored

// !LANGUAGE: +IntrinsicConstEvaluation
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K1: JVM_IR
fun <T> T.id() = this
class A(val OK: Int, val somePropertyWithLongName: String) {
fun foo() {}
suspend fun bar() {}
}
val topLevelProp = 1
const val propertyName1 = A::OK.<!EVALUATED("OK")!>name<!>
const val propertyName2 = A::somePropertyWithLongName.<!EVALUATED("somePropertyWithLongName")!>name<!>
const val methodName = A::foo.<!EVALUATED("foo")!>name<!>
const val suspendMethodName = A::bar.<!EVALUATED("bar")!>name<!>
const val className = ::A.<!EVALUATED("<init>")!>name<!>
const val topLevelPropName = ::topLevelProp.<!EVALUATED("topLevelProp")!>name<!>
const val nameInComplexExpression = A::OK.name <!EVALUATED("OK!")!>+ "!"<!>
// STOP_EVALUATION_CHECKS
fun box(): String {
if (propertyName1.id() != "OK") return "Fail 1"
if (propertyName2.id() != "somePropertyWithLongName") return "Fail 2"
if (methodName.id() != "foo") return "Fail 3"
if (suspendMethodName.id() != "bar") return "Fail 3.2"
if (className.id() != "<init>") return "Fail 4"
if (topLevelPropName.id() != "topLevelProp") return "Fail 5"
if (nameInComplexExpression.id() != "OK!") return "Fail 5"
return "OK"
}