-
Notifications
You must be signed in to change notification settings - Fork 82
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
Support explicit API mode for complex map keys #736
Support explicit API mode for complex map keys #736
Conversation
@@ -12,6 +12,10 @@ if (libs.versions.config.generateDaggerFactoriesWithAnvil.get().toBoolean()) { | |||
|
|||
dependencies { | |||
kapt libs.dagger2.compiler | |||
|
|||
// Necessary because this is what dagger uses when it runs to support instantiating annotations at runtime | |||
implementation libs.auto.value.annotations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why this is needed now and not before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As seen in that link, when unwrapValue = true
, it uses UnwrappedMapKeyGenerator
instead, which doesn't use @AutoAnnotation
.
Just to clarify:
Without
implementation libs.auto.value.annotations
kapt libs.auto.value.processor
we get
> Task :integration-tests:library:kaptKotlin
C:\Projects\anvil\integration-tests\library\build\tmp\kapt3\stubs\main\com\squareup\anvil\test\WrappedBindingKey.java:6: error: @AutoAnnotation is a necessary dependency if @MapKey(unwrapValue = false). Add a dependency for the annotation, "com.google.auto.value:auto-value-annotations:<current version>", and the annotation processor, "com.google.auto.value:auto-value:<current version>"
public abstract @interface WrappedBindingKey {
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sharing the extra context 👍
@@ -178,6 +178,7 @@ internal class MapKeyCreatorGenerator : PrivateCodeGenerator() { | |||
className, | |||
properties.entries.map { it.value.callExpression }.joinToCode() | |||
) | |||
.returns(className) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, coincidentally this is also needed for upgrading to newer KotlinPoet versions
@@ -12,6 +12,10 @@ if (libs.versions.config.generateDaggerFactoriesWithAnvil.get().toBoolean()) { | |||
|
|||
dependencies { | |||
kapt libs.dagger2.compiler | |||
|
|||
// Necessary because this is what dagger uses when it runs to support instantiating annotations at runtime | |||
implementation libs.auto.value.annotations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sharing the extra context 👍
Resolves #735