-
Notifications
You must be signed in to change notification settings - Fork 87
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
Update to dagger 2.50 #830
Conversation
.addFunction(createFactory("create", Provider::class.asClassName())) | ||
// New in Dagger 2.50: factories for dagger.internal.Provider | ||
.addFunction( | ||
FunSpec.builder("create") | ||
.jvmStatic() | ||
.addTypeVariables(typeParameters) | ||
.addParameter(DELEGATE_FACTORY_NAME, generatedFactoryTypeName) | ||
.returns(Provider::class.asClassName().parameterizedBy(baseFactoryTypeName)) | ||
.addStatement( | ||
"return %T.create(%T($DELEGATE_FACTORY_NAME))", | ||
InstanceFactory::class, | ||
implParameterizedTypeName, | ||
) | ||
.build(), | ||
createFactory("createFactoryProvider", dagger.internal.Provider::class.asClassName()), |
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.
Does Dagger always generate both now? Or are they keying off anything to decide on one vs the other? Looks like all the tests passed so it should be fine, but it feels a little surprising
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.
It always generates both now. The original for backward compatibility, the new one for forward compatibility. They're going to support both going forward
errrr I don't know what changed on main that broke this so much? It was green before |
Should be fixed up now 👍 |
... these pass locally for me. Ugh |
nvm found a new issue. I think this is a slight behavior difference between dagger kapt and KSP though, gonna dig in. Weird that these passed before though, curious what changed on main to trigger these in a way that didn't fail previously 🤔 |
I'm guessing it's related to the KotlinPoet bump. The
|
Sure, but I haven't made any changes to |
This updates Dagger to 2.50, which includes two code gen changes.
1. Prohibit extension declarations for
@Binds
functionsStarting in Dagger 2.48,
@Binds
functions can no longer be extension functions.Note that dagger also prohibits these on
@Provides
functions, but Anvil didn't have any tests or validation for this case. I added some opportunistically.2. Add support for new
dagger.internal.Provider
factoriesDagger 2.50 introduced a new
Provider
type in preparation for its support of jakarta: https://github.com/google/dagger/releases/tag/dagger-2.50. The way this is implemented in AssistedFactory code gen is via a secondcreateFactoryProvider()
factory function that returns an instance of this new internal Provider type. This PR updates Dagger and adds support for this new type.I had to also force a newer Guava version as it seems Dagger updated theirs and uses some newer APIs, though surprisingly this isn't exposed transitively on the classpath.