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 230938

Summary: [Introduce filed] Creating field with already used name produces not compilable code.
Product: java Reporter: Jiri Prox <jiriprox>
Component: HintsAssignee: Jan Lahoda <jlahoda>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P3    
Version: 7.4   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:

Description Jiri Prox 2013-06-07 16:05:01 UTC
Creating field with name which is already used in the current scope (variable or parameter in current method) produces not compilable code. But adding "this." would solve the problem

Example:
1) have a code:
    public void test() {
        final String temp = "";
        int c = 1;
        
    }

2) select "1" and call introduce field
3) type "temp" as a name of the new field and confirm

-> IDE generates:
   private int temp;

   public void test() {
        final String temp = "";
        temp = 1;   // <- incompatible types
        int c = temp; //<- incompatible types
        
    }

but the IDE can generate following code which is ok

   private int temp;

   public void test() {
        final String temp = "";
        this.temp = 1;   
        int c = this.temp; 
        
    }


Product Version: NetBeans IDE Dev (Build 20130606-5a346fc7541c)
Java: 1.8.0-ea; Java HotSpot(TM) 64-Bit Server VM 25.0-b31
Runtime: Java(TM) SE Runtime Environment 1.8.0-ea-b89
System: Windows 7 version 6.1 running on amd64; Cp1250; en_US (nb)
User directory: C:\Users\jprox\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\jprox\AppData\Local\NetBeans\Cache\dev
Comment 1 Jan Lahoda 2013-06-10 07:36:33 UTC

*** This bug has been marked as a duplicate of bug 205081 ***