mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-13 08:31:31 +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
27 lines
759 B
Kotlin
Vendored
27 lines
759 B
Kotlin
Vendored
import kotlin.reflect.*
|
|
|
|
var storage = "before"
|
|
|
|
class A {
|
|
val String.readonly: String
|
|
get() = this
|
|
|
|
var String.mutable: String
|
|
get() = storage
|
|
set(value) { storage = value }
|
|
}
|
|
|
|
fun box(): String {
|
|
val props = javaClass<A>().kotlin.memberExtensionProperties
|
|
val readonly = props.single { it.name == "readonly" }
|
|
assert(readonly !is KMutableProperty2<A, *, *>) { "Fail 1: $readonly" }
|
|
val mutable = props.single { it.name == "mutable" }
|
|
assert(mutable is KMutableProperty2<A, *, *>) { "Fail 2: $mutable" }
|
|
|
|
val a = A()
|
|
mutable as KMutableProperty2<A, String, String>
|
|
assert(mutable[a, ""] == "before") { "Fail 3: ${mutable.get(a, "")}" }
|
|
mutable[a, ""] = "OK"
|
|
return mutable.get(a, "")
|
|
}
|