https://kotlinlang.org logo
Title
n

nerses

09/28/2017, 8:59 PM
i think i’ve found a bug in kotlin converter, Java Code
Collection<Long> values = fetchList();
            Long[] valuesAsArray = new Long[values.size()];
            values.toArray(valuesAsArray);
Kotlin conversion
val values = fetchList()
            val valuesAsArray = arrayOfNulls<Long>(values.size)
            values.toTypedArray()
and all elements in valuesAsArray will be null
l

louiscad

09/28/2017, 9:08 PM
I think there's no bug. Typed arrays of non primitives have null values by default in java
n

nerses

09/28/2017, 9:12 PM
the bug is that valuesAsArray in java had the data
in kotlin it contains just nulls
m

m

09/28/2017, 9:14 PM
Java Code and Kotlin Code are different, aren’t they?
n

nerses

09/28/2017, 9:14 PM
yes and that’s the problem. i have converted using intellij java to kotlin converter
m

m

09/28/2017, 9:14 PM
In third line
Ah.. So you mean Idea conversion tool..
n

nerses

09/28/2017, 9:16 PM
kotlin code should be
val values = fetchList()
val valuesAsArray = values.toTypedArray()
yes
k

karelpeeters

09/28/2017, 9:17 PM
:youtrack:
n

nerses

09/28/2017, 9:43 PM