-
Notifications
You must be signed in to change notification settings - Fork 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
IllegalArgumentException via checkArgument in d.i.c.writing.InjectionMethod
could benefit from a message.
#1665
Comments
Another workaround worked for me is to rollback to 2.24. |
Another better option would likely be to add an additional check to //from validateMembersInjectionType(TypeElement)
if (hasInjectedMembers) {
checkInjectIntoPrivateClass(typeElement, builder);
checkInjectIntoKotlinObject(typeElement, builder);
} something like: private void checkInjectIntoKotlinObject(
TypeElement element, ValidationReport.Builder<TypeElement> builder) {
if (kotlinMetadataUtil.isObjectClass(element)) {
builder.addError(
"Dagger does not support injection into kotlin object's",
element);
}
} |
Should I add this into the |
I'd be happy to make the changes I was just hoping for some direction from the project maintaintainers before doing so. |
I'm on board with disallowing injection of object classes and companion objects, encouraging a scoped binding and if that doesn't work, as a migration path one can still have a provision method in the component to set the object's property. @trevjonez if you make a pull request I'll gladly pick it up and merge it internally. |
resolves root cause of issue google#1665
Fixes #1665 Closes #1739 RELNOTES=Disallow member injection of Kotlin object classes. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=294805598
Fixes #1665 Closes #1739 RELNOTES=Disallow member injection of Kotlin object classes. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=294805598
I just started working in a new project and am hitting a possible blocker for teams trying to update from older versions of dagger. I went from 2.9 to 2.25.2 and got this:
I set a breakpoint at the throw in the checkArgument and was able to back track to the source of the issue. What i found was something like this:
once I figured out where the issue was , I updated the injected property to:
Which results in the expected:
injection into static fields is not supported
Yes the stateful nature of the property is less than ideal and the best solution is probably a scoped instance rather than language singleton but at the least a more helpful info dump should ease the pain of the up and coming.
When debugging all the necessary info is in scope, so this _should_™ be a fairly straight forward addition once message formatting was decided.
The text was updated successfully, but these errors were encountered: