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 238268 - Rename lambda parameter checks wrong context for eligible parameter name
Summary: Rename lambda parameter checks wrong context for eligible parameter name
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Ralph Ruijs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-12 12:02 UTC by Jachym_Vojtek
Modified: 2014-11-11 12:15 UTC (History)
1 user (show)

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 Jachym_Vojtek 2013-11-12 12:02:45 UTC
Select labmda parameter 'x'->Right click->Refactor->Rename...
New Name: a

Dialog will show error: Cannot rename. a already used. But in fact the code:
        IntegerMath addition = (a, b) -> a + b;
        IntegerMath subtraction = (a, b) -> a - b;

is correct.


public class Calculator {

    interface IntegerMath {

        int operation(int a, int b);
    }

    public int operateBinary(int a, int b, IntegerMath op) {
        return op.operation(a, b);
    }

    public static void main(String... args) {

        Calculator myApp = new Calculator();
        IntegerMath addition = (a, b) -> a + b;
        IntegerMath subtraction = (x, y) -> x - y; // Try to rename 'x' to 'a'
        System.out.println("40 + 2 = "
                + myApp.operateBinary(40, 2, addition));
        System.out.println("20 - 10 = "
                + myApp.operateBinary(20, 10, subtraction));
    }
}
Comment 1 Ralph Ruijs 2014-10-20 11:09:16 UTC
changeset:   50a8acf6e8a9
user:        Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
date:        Mon Oct 20 13:05:03 2014 +0200
summary:     # 238268 - Rename lambda parameter checks wrong context for eligible parameter name
Comment 2 Jiri Prox 2014-11-04 08:21:48 UTC
verified in 

NetBeans IDE Dev (Build 20141104-d5433ace1b92)