mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 15:53:55 +00:00
Introduce MetadataSource as a way to store the original descriptor for any element (before any lowerings) and maintain it until the end of the codegen where it's used in generating the metadata. Note that JVM signatures written to the metadata are formed from the _resulting_ generated elements, not by mapping the original descriptors. Some corner cases are not supported yet, namely properties declared in companion objects, synthetic methods for property annotations, JvmPackageName, etc. #KT-29119 Fixed
36 lines
902 B
Kotlin
Vendored
36 lines
902 B
Kotlin
Vendored
// TARGET_BACKEND: JVM
|
|
// WITH_REFLECT
|
|
|
|
import kotlin.reflect.*
|
|
import kotlin.reflect.jvm.isAccessible
|
|
import kotlin.test.*
|
|
|
|
abstract class Base {
|
|
protected val protectedVal: String
|
|
get() = "1"
|
|
|
|
var publicVarProtectedSet: String = ""
|
|
protected set
|
|
|
|
protected fun protectedFun(): String = "3"
|
|
}
|
|
|
|
class Derived : Base()
|
|
|
|
fun member(name: String): KCallable<*> = Derived::class.members.single { it.name == name }.apply { isAccessible = true }
|
|
|
|
fun box(): String {
|
|
val a = Derived()
|
|
|
|
assertEquals("1", member("protectedVal").call(a))
|
|
|
|
val publicVarProtectedSet = member("publicVarProtectedSet") as KMutableProperty1<Derived, String>
|
|
publicVarProtectedSet.setter.call(a, "2")
|
|
assertEquals("2", publicVarProtectedSet.getter.call(a))
|
|
assertEquals("2", publicVarProtectedSet.call(a))
|
|
|
|
assertEquals("3", member("protectedFun").call(a))
|
|
|
|
return "OK"
|
|
}
|