-
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
MoreElements.getLocalAndInheritedMethods or alternative should resolve type parameters if applicable #653
Comments
The main problem is that the Eclipse compiler has never implemented Types.asMemberOf correctly. Some bugs have been fixed (382590 and 510118) but some remain (499026). That makes it hard to address otherwise reasonable requests like this, without throwing Eclipse users under the bus. |
@eamonnmcmanus good point, thanks for the explanation. For the record, as a workaround, I tackled this problem during code generation. I am using javapoet and they have |
I'm still not really sure what the best solution is here. For the record, if you're not afraid of the Eclipse bug, you should be able to replace the type parameters yourself in this somewhat non-obvious way: ExecutableElement originalMethod = ...;
Types types = processingEnv.getTypeUtils();
ExecutableElement replacedMethod =
MoreElements.asExecutable(types.asMemberOf(someType, originalMethod)); Yes, we do run into this issue in AutoValue and we work around it as best we can. |
@eamonnmcmanus yes, I did something like (but via javapoet).
Could you point me to where in the codebase this happen maybe? |
The main place is in EclipseHack. |
@eamonnmcmanus thanks, and why not expose this behaviour in auto common? I'm sure it will be useful to many :) |
I have the following class hierarchy:
Calling
MoreElements.getLocalAndInheritedMethods
on the element representingAnInterface
gives me a methodvoid test(A a)
instead of a methodvoid test(String a)
.If this is intended and there is no other recommended way to resolve type parameters like this, I think auto-common should include an helper to do so.
The text was updated successfully, but these errors were encountered: