Files
kotlin-fork/compiler/testData/codegen/box/reflection/classes/localClassSimpleName.kt
T
Mark Punzalan 36c4df6d99 [JVM IR] Use names of local functions in names of local classes.
This undoes changes in
https://github.com/JetBrains/kotlin/commit/fbe66c3496d082d2d487b2c39673f0cd4ac5b70a
which broke calculation of the simple name of local classes in
reflection (the enclosing method was not a substring of the name of the
local class).
2020-01-08 18:45:40 +01:00

44 lines
927 B
Kotlin
Vendored

// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: NATIVE
// WITH_RUNTIME
import kotlin.reflect.KClass
import kotlin.test.assertEquals
fun check(klass: KClass<*>, expectedName: String) {
assertEquals(expectedName, klass.simpleName)
}
fun localInMethod() {
fun localInMethod(unused: Any?) {
class Local
check(Local::class, "Local")
class `Local$With$Dollars`
check(`Local$With$Dollars`::class, "Local\$With\$Dollars")
}
localInMethod(null)
class Local
check(Local::class, "Local")
class `Local$With$Dollars`
check(`Local$With$Dollars`::class, "Local\$With\$Dollars")
}
class LocalInConstructor {
init {
class Local
check(Local::class, "Local")
class `Local$With$Dollars`
check(`Local$With$Dollars`::class, "Local\$With\$Dollars")
}
}
fun box(): String {
localInMethod()
LocalInConstructor()
return "OK"
}