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 200222

Summary: Provide Refactoring if return statement changes
Product: java Reporter: nigjo_iqn
Component: HintsAssignee: Jan Lahoda <jlahoda>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 7.0   
Hardware: PC   
OS: Windows XP   
Issue Type: ENHANCEMENT Exception Reporter:

Description nigjo_iqn 2011-07-19 07:55:23 UTC
When I (accidentally) create a method like this:

  public void getValue(){
    // do some stuff
  }

I realize that I missed the return type and statement. If I add this return statement, 
  public void getValue(){
    // do some stuff
    return 42;
  }
NetBeans only shows an error "cannot return a value from method whose result type is void".

It would be nice to provide a refactoring hint: "You typed a return statement which doesn't match the current return type. Should I
a) remove this return statement, or
b) change the return type"
Comment 1 Jan Lahoda 2011-07-26 19:20:09 UTC
Implemented:
http://hg.netbeans.org/main-silver?cmd=changeset;node=11e0fa752767
Comment 2 Quality Engineering 2011-07-27 14:10:28 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/11e0fa752767
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #200222: Provide Refactoring if return statement changes
Comment 3 doubleCortado 2011-11-08 12:35:04 UTC
Hi. Great new feature.
A couple of suggestion. How about having the option to modify the return type to void of no returns are specified?

Also, when implementing a method which overrides a superclass og implements an interface, how about getting the option to modify the signature of the overridden method?