ilyagulya
05/30/2024, 3:51 PMAnvil
part of @Zac Sweers post (interface merging part as well): https://www.zacsweers.dev/preparing-for-k2/
However, I’m getting a compilation error suggesting that interface merging was not in fact done:
Type mismatch: inferred type is ScreenComponent but UserDocumentsDependencies was expected
Type mismatch: inferred type is ScreenComponent but CatalogDependencies was expected
... etc
What is a proper way to debug this situation?Zac Sweers
05/30/2024, 4:19 PMilyagulya
05/30/2024, 4:36 PMScreenComponent
), example of how ScreenComponent
and (for instance) contributed UserDocumentDependencies
looks like.
https://gist.github.com/IlyaGulya/2b53e49ccc856a135dea065cdf179bd8
I’ve tried to attach a debugger to Gradle.
IrContributionMerger
seems to be registered:
IrGenerationExtension.registerExtension(
project,
IrContributionMerger(scanner, moduleDescriptorFactory),
)
But IrContributionMerger.generate
method never being called for some reason.ilyagulya
05/30/2024, 4:37 PMScreenComponent
to contributed interface’s lateinit var instance
inside its companion objectZac Sweers
05/30/2024, 4:38 PMilyagulya
05/30/2024, 4:41 PMAnvilComponentRegistrar
stops only in the compilation task, btw.ilyagulya
05/30/2024, 4:48 PMThe latter is what would affect your runtime cast
- that’s not runtime issue, but compile-time one.Zac Sweers
05/30/2024, 5:02 PMilyagulya
05/30/2024, 5:13 PMilyagulya
05/30/2024, 5:13 PM> Task :apps:base:store:compileInternalDebugKotlin FAILED
e: file:///Users/ilyagulya/Projects/Qantor/qa-android-apps/apps/base/store/src/main/java/ru/qantor/customer/presentation/CustomerApp.kt:155:54 Type mismatch: inferred type is ScreenComponent but UserDocumentsDependencies was expected
e: file:///Users/ilyagulya/Projects/Qantor/qa-android-apps/apps/base/store/src/main/java/ru/qantor/customer/presentation/CustomerApp.kt:156:48 Type mismatch: inferred type is ScreenComponent but CatalogDependencies was expected
e: file:///Users/ilyagulya/Projects/Qantor/qa-android-apps/apps/base/store/src/main/java/ru/qantor/customer/presentation/CustomerApp.kt:157:50 Type mismatch: inferred type is ScreenComponent but FavoritesDependencies was expected
e: file:///Users/ilyagulya/Projects/Qantor/qa-android-apps/apps/base/store/src/main/java/ru/qantor/customer/presentation/CustomerApp.kt:158:57 Type mismatch: inferred type is ScreenComponent but PersonalManagersDependencies was expected
e: file:///Users/ilyagulya/Projects/Qantor/qa-android-apps/apps/base/store/src/main/java/ru/qantor/customer/presentation/CustomerApp.kt:159:49 Type mismatch: inferred type is ScreenComponent but MarkdownDependencies was expected
e: file:///Users/ilyagulya/Projects/Qantor/qa-android-apps/apps/base/store/src/main/java/ru/qantor/customer/presentation/CustomerApp.kt:160:47 Type mismatch: inferred type is ScreenComponent but EventsDependencies was expected
ilyagulya
05/30/2024, 5:14 PMIrContributionMerger.generate
seems to be called in the modules with such configuration:
anvil {
useKsp(contributesAndFactoryGeneration = true)
generateDaggerFactories = true
}
But not in ones where I fallback Kapt and KotlinCompile tasks languageVersion
to 1.9
Zac Sweers
05/30/2024, 5:23 PMZac Sweers
05/30/2024, 5:24 PMilyagulya
05/30/2024, 5:24 PMilyagulya
05/30/2024, 5:50 PMMainKt
in :entrypoint
module and see the error:
Type mismatch: inferred type is SomeComponent! but Dependencies was expected
ilyagulya
06/27/2024, 4:01 PMSyntheticResolveExtension
which were deleted in these commit.
https://github.com/square/anvil/commit/c35bef587974c432371fffebb610122ccb96d89b
This happens because IR generation is running after analysis, and analysis fails because of absense of SyntheticResolveException
.
I’ve just checked that returning SyntheticResolveExtension
back fixes the issue.
I’m not sure what is the correct way to provide analyzer information about the supertypes which will be merged in the IR generation phase.
I’ve just checked the Parcelize plugin and it seems to use SyntheticResolveExtension
as well for this purpose.
Are you sure that it’s no longer required?
Seems that it should be preserved for K1 (I’m assuming this according to this message https://kotlinlang.slack.com/archives/C7L3JB43G/p1709191343204389?thread_ts=1709191090.501719&cid=C7L3JB43G)Zac Sweers
06/27/2024, 4:09 PMZac Sweers
06/27/2024, 4:10 PMilyagulya
06/27/2024, 4:33 PMZac Sweers
06/27/2024, 4:33 PMZac Sweers
06/27/2024, 4:33 PMZac Sweers
06/27/2024, 4:34 PMZac Sweers
06/27/2024, 4:34 PMZac Sweers
06/27/2024, 4:35 PMilyagulya
06/27/2024, 5:05 PMZac Sweers
06/27/2024, 6:25 PMZac Sweers
06/27/2024, 6:25 PMZac Sweers
06/27/2024, 6:25 PMZac Sweers
06/27/2024, 6:26 PMZac Sweers
06/27/2024, 6:26 PMZac Sweers
06/27/2024, 6:26 PMilyagulya
06/28/2024, 7:29 AMilyagulya
06/28/2024, 7:29 AMZac Sweers
06/28/2024, 3:43 PM