mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 08:31:29 +00:00
Also add a deprecated extension property to help migration. This is done to unify getting size of arrays and collections
18 lines
590 B
Kotlin
18 lines
590 B
Kotlin
data class A(a: Int, b: String) {}
|
|
|
|
fun box() : String {
|
|
for (method in javaClass<A>().getDeclaredMethods()) {
|
|
if (method.getName() == "copy"){
|
|
val parameterTypes = method.getParameterTypes()
|
|
if (parameterTypes != null && parameterTypes.size() == 2) {
|
|
val copy = A(1, "a").copy(a = 2, b = "b")
|
|
return "OK"
|
|
}
|
|
else {
|
|
return "Method copy has " + (if (parameterTypes == null) "0" else parameterTypes.size()) + " parameters, expected 2"
|
|
}
|
|
}
|
|
}
|
|
return "fail"
|
|
}
|