neilcsmith-net commented on code in PR #9173:
URL: https://github.com/apache/netbeans/pull/9173#discussion_r2747283259


##########
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:
   Yes, I assumed the point was that this should be checking the `Kind` from 
the element being casted?  Although like you say the current situation seems 
inconsistent.  I've looked through a few reports and stack traces before we've 
had with CCE, and I just get the feeling it might be better to verify types as 
well as kind before casting.  I wondered if we had a utility somewhere already 
that does that.  Bonus if it also checks for `null` first.  Could simplify a 
few bits of this while keeping the logic in one place.



-- 
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

Reply via email to