Community
Participate
Working Groups
Build ID: I20090803-1800 Steps To Reproduce: Ref: bug 213519 Testcase : 1. public class Snippet { void foo(){ ArrayList<Integer> list = new ArrayList<Integer>(); for (Integer var: list) { int a = 0; for (int count = 0; count < 10; count++) { list.add(a++); } } System.out.println(list.toString()); } } 2. Select 'list.add(a++);' Extract method gives the refactoring with 'void' as the return type: public class Snippet { void foo(){ ArrayList<Integer> list = new ArrayList<Integer>(); for (Integer var: list) { int a = 0; for (int count = 0; count < 10; count++) { zzzz(list, a); } } System.out.println(list.toString()); } private void zzzz(ArrayList<Integer> list, int a) { list.add(a++); } } 3. Select 'list.add(a++)' (without ;) Extract method gives a method with return type 'boolean' : public class Snippet { void foo(){ ArrayList<Integer> list = new ArrayList<Integer>(); for (Integer var: list) { int a = 0; for (int count = 0; count < 10; count++) { zzzz(list, a); } } System.out.println(list.toString()); } private boolean zzzz(ArrayList<Integer> list, int a) { return list.add(a++); } } More information:
Expected behaviour : return type should be int since we return 'a' : public class Snippet { void foo(){ ArrayList<Integer> list = new ArrayList<Integer>(); for (Integer var: list) { int a = 0; for (int count = 0; count < 10; count++) { a = zzzz(list, a); } } System.out.println(list.toString()); } private int zzzz(ArrayList<Integer> list, int a) { list.add(a++); return a; } }
The difference between selecting an ExpressionStatement (2.) and an Expression (3.) would be OK (see bug 285551), but we need to fix nested for loops for M2.
Ping! Benny, any plans to work on this?
(In reply to Dani Megert from comment #3) > Ping! Benny, any plans to work on this? Who's Benny? I don't see anyone by that name copied on the bug? Is this a duplicate of bug 488942?
(In reply to Jay Arthanareeswaran from comment #4) > (In reply to Dani Megert from comment #3) > > Ping! Benny, any plans to work on this? > Who's Benny? I don't see anyone by that name copied on the bug? Probably Benno who was in our team at some point. > Is this a duplicate of bug 488942? I would have to look at it which is something you can also do ;-).
(In reply to Dani Megert from comment #5) > > Is this a duplicate of bug 488942? > I would have to look at it which is something you can also do ;-). I see the symptoms being different and thought them to be different. But Dan in the below list suggests they are same. So, I thought someone who knows more about this could take the final call. https://www.eclipse.org/lists/jdt-dev/msg01159.html I suppose that would be Noopur?
I also think this is a dup of Bug 488942, please reopen if that was wrong. *** This bug has been marked as a duplicate of bug 488942 ***