Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

varargs ambiguity with generics #285

Copy link
Copy link
@henridf

Description

@henridf
Issue body actions
> 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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.