Make Array.size() a function instead of a property
Also add a deprecated extension property to help migration. This is done to unify getting size of arrays and collections
This commit is contained in:
@@ -22,11 +22,11 @@ fun box(): String {
|
||||
val e = javaClass<E>()
|
||||
|
||||
val e1 = e.getDeclaredField(E.E1.toString()).getAnnotations()
|
||||
if (e1.size != 1) return "Fail E1 size: ${e1.toList()}"
|
||||
if (e1.size() != 1) return "Fail E1 size: ${e1.toList()}"
|
||||
if (e1[0].annotationType() != javaClass<First>()) return "Fail E1: ${e1.toList()}"
|
||||
|
||||
val e2 = e.getDeclaredField(E.E2.toString()).getAnnotations()
|
||||
if (e2.size != 1) return "Fail E2 size: ${e2.toList()}"
|
||||
if (e2.size() != 1) return "Fail E2 size: ${e2.toList()}"
|
||||
if (e2[0].annotationType() != javaClass<Second>()) return "Fail E2: ${e2.toList()}"
|
||||
|
||||
return (e2[0] as Second).value
|
||||
|
||||
@@ -4,12 +4,12 @@ fun box() : String {
|
||||
for (method in javaClass<A>().getDeclaredMethods()) {
|
||||
if (method.getName() == "copy"){
|
||||
val parameterTypes = method.getParameterTypes()
|
||||
if (parameterTypes != null && parameterTypes.size == 2) {
|
||||
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 "Method copy has " + (if (parameterTypes == null) "0" else parameterTypes.size()) + " parameters, expected 2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ fun box(): String {
|
||||
return "Fail: an exception should be thrown"
|
||||
} catch (e: IllegalStateException) {
|
||||
val st = (e as java.lang.Throwable).getStackTrace()
|
||||
if (st.size < 5) {
|
||||
if (st.size() < 5) {
|
||||
return "Fail: very small stack trace, should at least have current function and JUnit reflective calls: ${Arrays.toString(st)}"
|
||||
}
|
||||
val top = st[0]
|
||||
|
||||
@@ -18,7 +18,7 @@ fun box(): String {
|
||||
val method = javaClass<A>().getDeclaredMethod("a", javaClass<B>())
|
||||
val genericParameterTypes = method.getGenericParameterTypes()
|
||||
|
||||
if (genericParameterTypes.size != 1) return "Wrong number of generic parameters"
|
||||
if (genericParameterTypes.size() != 1) return "Wrong number of generic parameters"
|
||||
|
||||
if (genericParameterTypes[0].toString() != "T") return "Wrong parameter type ${genericParameterTypes[0].toString()}"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun <T> foo(vararg a: T) = a.size
|
||||
fun <T> foo(vararg a: T) = a.size()
|
||||
|
||||
inline fun <reified T> bar(a: Array<T>, block: () -> T): Array<T> {
|
||||
assertEquals(4, foo(*a, block(), block()))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun <T> foo(vararg a: T) = a.size
|
||||
fun <T> foo(vararg a: T) = a.size()
|
||||
|
||||
inline fun <reified T> bar(block: () -> T): Array<T> {
|
||||
assertEquals(2, foo(block(), block()))
|
||||
@@ -20,7 +20,7 @@ fun box(): String {
|
||||
assertEquals("234", b.map { it.toString() }.join(""))
|
||||
|
||||
val c: Array<String> = empty()
|
||||
assertEquals(0, c.size)
|
||||
assertEquals(0, c.size())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user