Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349045 - [1.7][extract local] Extract Local Variable must expand diamond type argument
Summary: [1.7][extract local] Extract Local Variable must expand diamond type argument
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7.1   Edit
Assignee: Raksha Vasisht CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-10 10:47 EDT by Markus Keller CLA
Modified: 2011-08-02 05:45 EDT (History)
2 users (show)

See Also:
markus.kell.r: review+


Attachments
Patch (1.73 KB, patch)
2011-06-14 02:49 EDT, Raksha Vasisht CLA
no flags Details | Diff
Patch + tests (6.71 KB, patch)
2011-06-27 18:04 EDT, Raksha Vasisht CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2011-06-10 10:47:35 EDT
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;
Comment 1 Raksha Vasisht CLA 2011-06-14 02:49:46 EDT
Created attachment 197940 [details]
Patch

Proposed fix.

Markus, could you pls review? I will add the tests if the fix is ok.
Comment 2 Markus Keller CLA 2011-06-21 08:22:09 EDT
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.
Comment 3 Raksha Vasisht CLA 2011-06-27 18:04:07 EDT
Created attachment 198693 [details]
Patch + tests

Patch with the null check + tests.
Comment 4 Raksha Vasisht CLA 2011-06-27 18:20:31 EDT
(In reply to comment #3)
> Created attachment 198693 [details] [diff]
> Patch + tests
> 
> Patch with the null check + tests.

Committed to HEAD.
Comment 5 Raksha Vasisht CLA 2011-06-27 18:21:49 EDT
> Committed to HEAD.

Oops,  I mean to BETA_JAVA7 branch.
Comment 6 Jay Arthanareeswaran CLA 2011-07-20 05:13:56 EDT
Verified.