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: | Too many return values. | ||
---|---|---|---|
Product: | java | Reporter: | kimsp <kimsp> |
Component: | Hints | Assignee: | Svata Dedic <sdedic> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 8.0 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: | IDE log |
Description
kimsp
2014-01-29 13:46:24 UTC
Created attachment 144540 [details]
IDE log
Please give a complete sample. When I created a testcase using the provided code, everything worked OK. public abstract class ClassA { public void test() { List<ClassA> objects = new ArrayList<>(); Iterable<String> strings = Iterables.transform(objects, new Function<ClassA, String>() { @Override public String apply(ClassA f) { return f.toString(); } }); } } ... selected whole lines from "Iterable<String>" to "});" inclusive, Alt-enter, Introduce method. The message may indicate that your code modifies some local variable whose value is used later in the original function. Hi Svata In your example try to include this line System.err.println(strings); after the: }); That is, you print out the contents of strings. Then you cannot select the lines you say without getting a Too Many return values. I have example code here: // all below is inside an existing method List<String> objects = new ArrayList<String>(); Iterable<String> strings = Iterables.transform(objects, new Function<String, String>() { @Override public String apply(String f) { return f.toString(); } }); //Above code I can't refactor if I have this system err commented in. System.err.println(strings); List<String> stringsTwo = new ArrayList<String>(); stringsTwo.add("a"); stringsTwo.add("b"); stringsTwo.add("c"); //The above lines (stringsTwo declaration + insertions) I can refactor to a method. Even though I have this system err commented in. System.err.println(stringsTwo); Great; return was counted as an exit point from the method although it was actually a return from a nested class. The same issue would happen for returns from lambda code blocks or break-continue in nested classes/lambdas. Fixed in jet-main#9e2ea831f168 Integrated into 'main-silver', will be available in build *201402140001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/9e2ea831f168 User: Svata Dedic <sdedic@netbeans.org> Log: #241120: do not count exit points of nested classes and lambdas |