mbien commented on code in PR #6658:
URL: https://github.com/apache/netbeans/pull/6658#discussion_r1406274480
##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaPreconditionChecker.java:
##########
@@ -137,9 +137,48 @@ private MethodTree
getMethodFromFunctionalInterface(TreePath pathToNewClassTree)
candidate = (MethodTree)member;
}
}
+ // default methods can't be implemented with a lambda
+ ExecutableElement candidateElement = (ExecutableElement)
info.getTrees().getElement(new TreePath(pathToNewClassTree, candidate));
+ if (overridesDefaultMethod(candidateElement, (TypeElement)
baseElement)) {
+ return null;
+ }
return candidate;
}
+ private boolean overridesDefaultMethod(ExecutableElement method,
TypeElement superType) {
+ Boolean overrides = overridesDefaultMethodImpl(method, superType);
+ return overrides != null && overrides;
+ }
+
+ private Boolean overridesDefaultMethodImpl(ExecutableElement method,
TypeElement superType) {
+ List<? extends VariableElement> methodParams = method.getParameters();
+ for (Element e : superType.getEnclosedElements()) {
Review Comment:
I remember looking at the method, but then thinking that the filter step
seems unnecessary since the && concatenated checks are both really efficient
and also already easy to read. This would add an extra pre-filter-step and we
would have to run all the subsequent checks anyway.
I take another look in context with your next suggestion
(`Elements.overrides`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists