| Summary: | [1.7][extract local] Extract Local Variable must expand diamond type argument | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Markus Keller <markus.kell.r> | ||||||
| Component: | UI | Assignee: | Raksha Vasisht <raksha.vasisht> | ||||||
| Status: | VERIFIED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | jarthana, markus.kell.r | ||||||
| Version: | 3.7 | Flags: | markus.kell.r:
review+
|
||||||
| Target Milestone: | 3.7.1 | ||||||||
| Hardware: | All | ||||||||
| OS: | All | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
Created attachment 197940 [details]
Patch
Proposed fix.
Markus, could you pls review? I will add the tests if the fix is ok.
The fix is at the right spot, but the typeBinding could theoretically be null (though I couldn't come up with an example that actually fails).
Nevertheless, the added check would better be this, so that in weird situations with non-compiling code, the user just gets the type from the CIC node:
&& (typeBinding == null || typeBinding.getTypeArguments().length == 0)
If you agree with this, please go ahead and release with the test(s) in ExtractTempTests17.
Created attachment 198693 [details]
Patch + tests
Patch with the null check + tests.
(In reply to comment #3) > Created attachment 198693 [details] [diff] > Patch + tests > > Patch with the null check + tests. Committed to HEAD. > Committed to HEAD.
Oops, I mean to BETA_JAVA7 branch.
Verified. |
BETA_JAVA7 Extract Local Variable must expand the diamond type argument here: List<Integer> m() { return new ArrayList<>(); } Extract Method correctly uses ArrayList<Integer> as return type but Extract Local Variable produces an erroneous variable type: ArrayList<> arrayList = new ArrayList<>(); return arrayList;