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

Annotating method parameters with @Inject results in ClassCastException #112

Closed
gunnarmorling opened this Issue Nov 17, 2012 · 0 comments

Comments

2 participants
@gunnarmorling

gunnarmorling commented Nov 17, 2012

When putting the @Inject annotation to a method parameter a ClassCastException is thrown in InjectProcessor#getInjectedClasses():

java.lang.ClassCastException: com.sun.tools.javac.code.Symbol$MethodSymbol cannot be cast to javax.lang.model.element.TypeElement
at dagger.internal.codegen.InjectProcessor.getInjectedClasses(InjectProcessor.java:76)
at dagger.internal.codegen.InjectProcessor.process(InjectProcessor.java:58)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)

That exception hides the error which would be thrown by the compiler due to the annotation being given at an unsupported element type ("annotation type not applicable to this kind of declaration").

JakeWharton added a commit that referenced this issue Mar 27, 2013

Add restrictions around injectable targets.
 * Private fields are not supported.
 * Private constructors are not supported.
 * Methods are not supported.

Closes #181. Closes #113. Closes #112.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment