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.
Summary: | Remove unnecessary return statement removes code | ||
---|---|---|---|
Product: | java | Reporter: | _ gtzabari <gtzabari> |
Component: | Hints | Assignee: | Svata Dedic <sdedic> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P3 | ||
Version: | 8.2 | ||
Hardware: | PC | ||
OS: | Windows 10 x64 | ||
Issue Type: | DEFECT | Exception Reporter: |
Description
_ gtzabari
2016-06-01 02:12:15 UTC
There are cases when the entire statement could be removed; the choice mainly depends on the user. However removing 'return' could be quite tricky - not all expressions can be interpreted as statement, c.f. statements like return s.length() + 1; return empty ? s : null; return checkFoo() || checkBar(); Even in the best case ;) the transformed code will likely break synchronization rules, i.e. private volatile int foo; ... return s.length() + foo; will transform into s.length(); and will not trigger the half-synchronization on 'foo'. If you can't apply the hint safely then the hint shouldn't be provided in the first place :) Either way, the hint should never result in data loss :) fixed in jet-main#fe39387af38a(In reply to _ gtzabari from comment #2) > If you can't apply the hint safely then the hint shouldn't be provided in > the first place :) Either way, the hint should never result in data loss :) Well, the fix did exactly what its label said: it removed the [entire] return statement. New hint fix added in jet-main#fe39387af38a Integrated into 'main-silver', will be available in build *201607190002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/fe39387af38a User: Svata Dedic <sdedic@netbeans.org> Log: #262290: Return expression can be retained as series of statements |