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 - Provide Refactoring if return statement changes
Summary: Provide Refactoring if return statement changes
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.0
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-19 07:55 UTC by nigjo_iqn
Modified: 2011-11-08 12:35 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

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