lahodaj commented on code in PR #9173:
URL: https://github.com/apache/netbeans/pull/9173#discussion_r2745058681
##########
java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java:
##########
@@ -5996,7 +5996,7 @@ private Set<? extends TypeMirror> getSmartTypesImpl(Env
env) throws IOException
path = new TreePath(path, mid);
TypeMirror typeMirror =
controller.getTrees().getTypeMirror(path);
final ExecutableType midTM = typeMirror != null &&
typeMirror.getKind() == TypeKind.EXECUTABLE ? (ExecutableType) typeMirror :
null;
- final ExecutableElement midEl = midTM == null ? null :
(ExecutableElement) controller.getTrees().getElement(path);
+ final ExecutableElement midEl = midTM != null &&
controller.getTrees().getElement(path) instanceof ExecutableElement ee ? ee :
null;
Review Comment:
Using `instanceof` on `Element`s is formally speaking not correct
(`getKind()` should be used), as one implementation type can implement multiple
API interfaces. Although I think use of `instanceof` will be accepted more and
more. And it is not so bad for `Element`, as I don't recall implementation
classes where this would be a real problem. (It is definitely a problem for
certain `TypeMirror`s - the implementation type `ClassType` implements both
`DeclaredType` and `ErrorType` API interfaces, and this effectively cannot be
changed while keeping all other things working reasonably. There are also some
rare `Tree`s where this is true.)
--
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