mbien commented on code in PR #6658:
URL: https://github.com/apache/netbeans/pull/6658#discussion_r1410073569
##########
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));
Review Comment:
> should we rather check the method implements an abstract interface method,
rather than checking it is not default? (Meaning, if the method based is not
found, we don't try to do the conversion?)
good thinking! I focused on default methods so much that I didn't see the
inverted variant. This should be more efficient in most cases abstract methods
are easier to find and the hint wouldn't have to search the whole hierarchy.
> should this be moved to be part of ensurePreconditionsAreChecked? (And
then passesAllPreconditions and passesFatalPreconditions?)
I haven't implemented this so far. since the method
`getMethodFromFunctionalInterface` is wrong without the change - it would
return a method even when the interface is not functional. The precondition
checks are all working, since the existence of the method is part of the checks.
Please take another look if you agree, if not I can still make it a
precondition - but we probably should also rename the method. Also please note
that many methods are actually unused. E.g `passesAllPreconditions` isn't used
anywhere which means the test coverage is also not ideal atm.
--
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