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 - [Introduce filed] Creating field with already used name produces not compilable code.
Summary: [Introduce filed] Creating field with already used name produces not compilab...
Status: RESOLVED DUPLICATE of bug 205081
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-07 16:05 UTC by Jiri Prox
Modified: 2013-06-10 07:36 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***