mbien commented on code in PR #9450:
URL: https://github.com/apache/netbeans/pull/9450#discussion_r3443948437
##########
java/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/NPECheckTest.java:
##########
@@ -1970,6 +2001,26 @@ enum E {A}
.assertWarnings("9:12-9:21:verifier:ERR_NotNull");
}
+ public void testIfAndInstanceOf() throws Exception {
+ HintTest.create()
+ .sourceLevel("21")
+ .input("""
+ package test;
+ public class Test {
+ public @NotNull Object test(Object o) {
+ if (o instanceof String s) {
+ return s;
+ } else {
+ return o; //can't say anything
Review Comment:
`o` would be no String (including null).
To assert the `@NotNull` requirement the method would have to add a check to
the else branch.
If removing the state simplifies things this might be fine, but this does
also remove a potentially useful warning, no?
--
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