Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 491552

Summary: [1.8] Convert to lambda expression quick assist does unnecessary renames
Product: [Eclipse Project] JDT Reporter: Marc-AndrĂ© Laperle <malaperle>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: julian.honnen, matthew.khouzam, noopur_gupta
Version: 4.6   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug
Attachments:
Description Flags
Sample project none

Description Marc-André Laperle CLA 2016-04-12 18:28:35 EDT
Created attachment 260906 [details]
Sample project

Using Eclipse 4.6-I20160412-0800

When trying to convert an anonymous class to a lambda expression, a quick assist is offered. If the body of the expression contains two variables with the same name but in different scopes, they get unnecessarily renamed.

I attached a sample project to show this behavior:

public class Main {
    public static void main(String[] args, Set<String> set) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                int i = 0;
                if (i == 0) {
                    int foo = 0;
                    System.out.println(foo);
                } else {
                    int foo = 1;
                    System.out.println(foo);
                }
            }
        });
    }
}


1. Import the project
2. Place the cursor on 'new Runnable'
3. Press Ctrl+1 to invoke quick assist
4. Press the down arrow key to select "Convert to lambda expression"
5. Press Enter.

The two 'foo' variables are renamed foo1 and foo2. This should not be necessary.
Comment 1 Eclipse Genie CLA 2019-12-30 03:52:57 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.