Annotating method parameters with @Inject results in ClassCastException #112

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

Projects

None yet

2 participants

@gunnarmorling

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 JakeWharton added a commit that referenced this issue Mar 27, 2013
@JakeWharton JakeWharton 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.
e332b64
@JakeWharton JakeWharton added a commit that closed this issue Mar 27, 2013
@JakeWharton JakeWharton 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.
b619788
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment