Bug 494283 - [quick fix] Allow for assigning varargs arguments to a new local variable (or field, etc.)
Summary: [quick fix] Allow for assigning varargs arguments to a new local variable (or...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday, helpwanted
Depends on:
Blocks:
 
Reported: 2016-05-23 06:31 EDT by Lukas Eder CLA
Modified: 2016-05-25 13:17 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Eder CLA 2016-05-23 06:31:46 EDT
Consider the following code:

---------------------------------------------
public class Test {
    void method() {
        varargs("a", 1, 2, 3);
    }

    void varargs(String x, Object... objects) {

    }
}
---------------------------------------------

In method "method()", the argument list "1, 2, 3" is really an Object[] array. When selecting "1, 2, 3", I would like to be able to assign that array to a local variable, field, etc., just like any other argument. The result would be something like:

---------------------------------------------
public class Test {
    void method() {
        Object[] objects = { 1, 2, 3 };
        varargs("a", objects);
    }

    void varargs(String x, Object... objects) {

    }
}
---------------------------------------------
Comment 1 Markus Keller CLA 2016-05-25 13:17:00 EDT
Sounds good. The array type should be readily available in the MethodInvocation's method binding (necessary in case the vararg type refers to a type variable).