mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-13 08:31:31 +00:00
24 lines
601 B
Kotlin
Vendored
24 lines
601 B
Kotlin
Vendored
import kotlin.reflect.*
|
|
|
|
class A(param: String) {
|
|
val int: Int get() = 42
|
|
val string: String = param
|
|
var anyVar: Any? = null
|
|
|
|
val List<IntRange>.extensionToList: Unit get() {}
|
|
|
|
fun notAProperty() {}
|
|
}
|
|
|
|
fun box(): String {
|
|
val klass = A::class.java.kotlin
|
|
|
|
val props = klass.memberProperties
|
|
|
|
val names = props.map { it.name }.sorted()
|
|
assert(names == listOf("anyVar", "int", "string")) { "Fail names: $props" }
|
|
|
|
val stringProp = props.firstOrNull { it.name == "string" } ?: return "Fail, string not found: $props"
|
|
return stringProp.get(A("OK")) as String
|
|
}
|