This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 235564

Summary: Rename refactor can break code when new name shadows existing name
Product: java Reporter: David Strupl <dstrupl>
Component: RefactoringAssignee: Ralph Ruijs <ralphbenjamin>
Status: RESOLVED FIXED    
Severity: normal CC: briangoetz, dbalek
Priority: P3    
Version: 7.3   
Hardware: PC   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description David Strupl 2013-09-05 14:49:21 UTC
This report is about the remaining case from bug report #104551.

This happens with all kinds of variables, not just local variables.  For 
example:

public class Foo {

    public int x;
    
    public class Inner {
        public int y;
        
        public void foo() { 
            y = x + 1;
        }
    }
}

Again, renaming y to x in the inner class, Netbeans changes the assignment, 
changing the semantics of the code, to:
            x = x + 1;

where the right answer is:

            x = Foo.this.x + 1;
Comment 1 Ralph Ruijs 2014-01-07 21:27:27 UTC
changeset   : 0067029ba850
author      : Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
date        : Tue Jan 07 16:02:27 CET 2014
summary     : #235564 - Rename refactor can break code when new name shadows existing name
Comment 2 Quality Engineering 2014-01-09 02:56:54 UTC
Integrated into 'main-silver', will be available in build *201401090002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/0067029ba850
User: Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
Log: #235564 - Rename refactor can break code when new name shadows existing name