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 206787 - Incorrect "Remove Unnecessary Return" hint inside switch block
Summary: Incorrect "Remove Unnecessary Return" hint inside switch block
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-29 14:59 UTC by _ gtzabari
Modified: 2012-02-13 15:34 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 _ gtzabari 2011-12-29 14:59:53 UTC
Product Version: NetBeans IDE Dev (Build 201112250601)
Java: 1.7.0_02; Java HotSpot(TM) Client VM 22.0-b10
System: Windows 7 version 6.1 running on x86; Cp1252; en_US (nb)
User directory: C:\Users\g.tzabari\.netbeans\dev
Cache directory: C:\Users\g.tzabari\.netbeans\dev\var\cache

1. Given:

void foo()
{
  int value = 5;
  switch (value)
  {
    case 1:
    {
      System.out.println("1");
      return;
    }
    case 2:
    {
      System.out.println("2");
      break;
    }
  }
}

2. A hint will pop up recommending the removal of the return statement, but in this particular case its removal causes case 1 to leak into case 2, which is not equivalent to the original logic.
3. Expected behavior: Suppress the hint for this condition.
Comment 1 Jiri Prox 2012-01-02 11:16:13 UTC
reproducible
Comment 2 Jan Lahoda 2012-01-06 20:18:58 UTC
Thank you very much for the report, should be OK:
http://hg.netbeans.org/jet-main/rev/dcdfeea082b8
Comment 3 Quality Engineering 2012-01-08 15:43:45 UTC
Integrated into 'main-golden', will be available in build *201201080601* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/dcdfeea082b8
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #206787: more precise handling of returns in switch's cases in unnecessary return hint
Comment 4 Jiri Prox 2012-02-06 11:10:51 UTC
verified in the trunk
Comment 5 Jan Lahoda 2012-02-06 21:52:32 UTC
releases71_fixes:
http://hg.netbeans.org/releases/rev/5fca317aa749
Comment 6 Quality Engineering 2012-02-08 02:32:38 UTC
Integrated into 'releases', will be available in build *201202072200* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/5fca317aa749
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #206787: more precise handling of returns in switch's cases in unnecessary return hint
(transplanted from dcdfeea082b85f164354189b1d232f13850d0f2c)
Comment 7 Jiri Prox 2012-02-13 15:34:36 UTC
verified in patch1