Closed
Description
> var Arrays = java.import('java.util.Arrays');
> var list = Arrays.asList(['a', 'b']);
> list.toArray();
[ [ 'a', 'b' ] ] // should be ['a', 'b'] !!
I haven't looked at the varargs handling code, but I'm assuming it's because of the ambiguity due to the asList
method being generic (List<T> asList(T... a)
) - there's no way to distinguish if the javascript Array being passed into Arrays.asList() is intended as a single value of type T
or if it's intended as a T[]
.
Assuming that's the issue, we could detect this ambiguity and throw an error, requiring the javascript programmer to use apply when they want a javascript array to be 'spread' into a varargs generic function.
Does this make sense?
(Btw, ES6 compiled by babel works just fine here with Arrays.asList(...arr);
).
Metadata
Metadata
Assignees
Labels
No labels