Akasha Peppermint
10/13/2020, 5:26 AMkralli
10/13/2020, 7:59 AMArray<T>
are not implemented in Kotlin, but rather are mapped to platform types. Those files you are looking are not the actual definition of those types, but rather documentation. Build-in types are handled by the compiler differently compared to normal code. In your case, the compiler will perform whats known as an intrinsic. It will replace the call to the array constructor by inlining a function that looks a bit like this:
inline fun <reified T> Array(size: Int, init: (Int) -> T): Array<T> {
val result = arrayOfNulls<T>(size)
for (i in 0 until size) {
result[i] = init(i)
}
return result as Array<T>
}
kralli
10/13/2020, 8:01 AM