mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 00:21:32 +00:00
Delete the old ones in package kotlin.reflect.jvm because otherwise the code using those functions will become red in a lot less meaningful way (overload resolution ambiguity) than if they're deleted (unresolved import) Based on the work originally done by @dnpetrov #KT-8380 Fixed
20 lines
607 B
Kotlin
Vendored
20 lines
607 B
Kotlin
Vendored
import kotlin.reflect.*
|
|
|
|
class A(val readonly: String) {
|
|
var mutable: String = "before"
|
|
}
|
|
|
|
fun box(): String {
|
|
val props = javaClass<A>().kotlin.memberProperties
|
|
val readonly = props.single { it.name == "readonly" }
|
|
assert(readonly !is KMutableProperty1<A, *>) { "Fail 1: $readonly" }
|
|
val mutable = props.single { it.name == "mutable" }
|
|
assert(mutable is KMutableProperty1<A, *>) { "Fail 2: $mutable" }
|
|
|
|
val a = A("")
|
|
mutable as KMutableProperty1<A, String>
|
|
assert(mutable[a] == "before") { "Fail 3: ${mutable.get(a)}" }
|
|
mutable[a] = "OK"
|
|
return mutable.get(a)
|
|
}
|