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

Bug 141555

Summary: [inline] inlining same method twice gives duplicate local variable
Product: [Eclipse Project] JDT Reporter: Genady Beryozkin <eclipse>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: b.muskalla
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Genady Beryozkin CLA 2006-05-12 11:13:03 EDT
I have the following utility method (local variable named incorrectly):

    private static void saveTextualProperty(IProject proj, String name, String val) 
        throws CoreException 
    {
		IScopeContext context = new ProjectScope(proj);
		IEclipsePreferences eclipsePreferences = context.getNode(RMIPlugin.PLUGIN_ID);
        if (val == null || "".trim().equals(val)) {
            eclipsePreferences.remove(name);
        } else {
        	eclipsePreferences.put(name, val);
        }
    }


In another method I have two calls to this method:

    private static void xxxx() {
        saveTextualProperty(null, XXX1, "XXXX");
        saveTextualProperty(null, XXX2, "XXXXX");

    }

When I inline the first method the result is:

    private static void xxxx() {
        IScopeContext context = new ProjectScope(null);
		IEclipsePreferences eclipsePreferences = context.getNode(RMIPlugin.PLUGIN_ID);
		if ("XXXX" == null || "".trim().equals("XXXX")) {
		    eclipsePreferences.remove(XXX1);
		} else {
			eclipsePreferences.put(XXX2, "XXXX");
		}
        IScopeContext context = new ProjectScope(null);
		IEclipsePreferences eclipsePreferences = context.getNode(RMIPlugin.PLUGIN_ID);
		if ("XXXXX" == null || "".trim().equals("XXXXX")) {
		    eclipsePreferences.remove(XXX2);
		} else {
			eclipsePreferences.put(XXX2, "XXXXX");
		}

    }

If the method already has a variable named "context" then the new "context" variables are correctly renamed to "context1" and "context2".
Comment 1 Genady Beryozkin CLA 2006-05-12 11:16:09 EDT
happens in 3.2RC3
Comment 2 Markus Keller CLA 2006-06-13 11:59:29 EDT
To reproduce:

public class Try {
	void toInline(String arg) {
		String temp= arg;
		System.out.println(temp);
	}
	
	void caller() {
		toInline("me");
		toInline("too");
	}
}
Comment 3 Eclipse Genie CLA 2020-05-15 13:12:01 EDT
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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.