dennis lucero created NETBEANS-3755: ---------------------------------------
Summary: "Can use functional operations" hint creates uncompilable code with nested loops (Unexpected return value) Key: NETBEANS-3755 URL: https://issues.apache.org/jira/browse/NETBEANS-3755 Project: NetBeans Issue Type: Bug Components: java - Hints Affects Versions: 11.2 Environment: OpenJDK 13+33 Reporter: dennis lucero Consider this code: {code:java} private static boolean deepContains( final String needle, final Collection<Collection<String>> haystack) { for (final Collection<String> hay : haystack) { for (final String check : hay) { if (check.equals(needle)) { return true; } } } return false; } {code} NetBeans suggests to replace the outer loop with with a functional operation, resulting in {code:java} private static boolean deepContains( final String needle, final Collection<Collection<String>> haystack) { haystack.forEach((hay) -> { for (final String check : hay) { if (check.equals(needle)) { return true; } } }); return false; } {code} This does not compile. Error messages: For the outer loop: {quote}incompatible types: unexpected return value {quote} For the inner loop: {quote}for-each not applicable to expression type required: array or java.lang.Iterable found: T where T is a type-variable: T extends Object declared in interface Iterable {quote} -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists