Files
kotlin-fork/compiler/testData/codegen/boxWithStdlib/reflection/properties/memberAndMemberExtensionWithSameName.kt
T
Alexander Udalov 8d9618348d Move .java and .kotlin extension properties to kotlin.jvm
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
2015-08-27 08:19:50 +03:00

24 lines
701 B
Kotlin
Vendored

import kotlin.reflect.*
class A {
val foo: String = "member"
val Unit.foo: String get() = "extension"
}
fun box(): String {
run {
val foo: KProperty1<A, *> = javaClass<A>().kotlin.memberProperties.single()
assert(foo.name == "foo") { "Fail name: $foo (${foo.name})" }
assert(foo.get(A()) == "member") { "Fail value: ${foo[A()]}" }
}
run {
val foo: KProperty2<A, *, *> = javaClass<A>().kotlin.memberExtensionProperties.single()
assert(foo.name == "foo") { "Fail name: $foo (${foo.name})" }
foo as KProperty2<A, Unit, *>
assert(foo.get(A(), Unit) == "extension") { "Fail value: ${foo[A(), Unit]}" }
}
return "OK"
}