-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BasicAnnotationProcessor does not recursively validate superclasses / superinterfaces #660
Comments
I'm not positive, but I think here:
If we also check |
That's what I was initially thinking as well. The problem is that this will result in a cycle since private static boolean isValidBaseElement(Element e) {
return validateType(e.asType())
&& validateAnnotations(e.getAnnotationMirrors())
&& validateElements(e.getEnclosedElements());
} |
It's possible we need to pass some state around for previously visited elements/types. Or we can change isValidBaseElement? |
So to clarify some options:
|
@eamonnmcmanus would love to get your thoughts on here. We just had another person report a similar issue in Dagger that appears to be a manifestation of this bug. |
@Leland-Takamine I tried option 2, but that is also stack-overflowing. Hrm. |
Certainly the second approach (just iterate up the hierarchy) is easier to understand and less susceptible to infinite recursion. I would include a test where a class does extend itself, since we're talking about detecting incorrect code here. Probably such a class would never even reach the annotation processing stage, but I'm not sure. It's possible for a class or interface to inherit from the same interface along more than one path, but it's probably not worth handling that specially since at worst we would just make the same checks more than once. (Incidentally I'm not particularly expert on this code. AutoValue doesn't use it, because as I recall it doesn't interact well with the round-deferment we do in order to handle references to classes that have not yet been generated but will be.) |
@ronshapiro That's surprising - would you mind pushing up a branch with those changes? |
@eamonnmcmanus @ronshapiro Pushed a PR up - let me know what you think. |
Is there any plan on how we are to proceed from here? Been keeping on an eye on this issue for a while now. |
BasicAnnotationProcessor
only validates immediate superclass and superinterfaces. This commit demonstrates the behavior. The first test passes, but the second fails. It's possible to updateSuperficialValidation
to recursively validate superclasses and superinterfaces. Is this something thatBasicAnnotationProcessor
should support?The text was updated successfully, but these errors were encountered: