I told IntillJ to auto-generate an external annotation for Dagger's ObjectGraph.get. However, I am still getting possible NPE warnings when I try to access the return value of the method.
final ServiceManager serviceManager = objectGraph.get(ServiceManager.class);
serviceManager.startAsync().awaitHealthy(2, TimeUnit.MINUTES); // possible NPE on serviceManager.startAsync()
If I put an assert serviceManager != null inbetween the two lines the warning goes away, validating that the problem is with IntelliJ thinking that get can return null.
My annotation file lives in <source root>/Dagger/annotation.xml (auto-generated) and looks like this:
<item name='dagger.ObjectGraph.DaggerObjectGraph T get(java.lang.Class<T>)'>
My other external annotations (e.g., for logback and guava) are working correctly, all were auto-generated by IntelliJ in similar locations (<source root>/package/name/annotation.xml)
Here are the docs for the method I am trying to annotate: https://square.github.io/dagger/javadoc/dagger/ObjectGraph.html#get(java.lang.Class)