Skip to content
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 Anvil 2.4.4 and use new TopLevelFunctionReference #277

Merged
merged 2 commits into from
Jan 27, 2023

Conversation

gabrielittner
Copy link
Member

@gabrielittner gabrielittner commented Jan 13, 2023

Updates Kotlin to 1.8.0, Compose Compiler to 1.4.0 and Anvil to 2.4.4. Anvil now offers a TopLevelFunctionReference abstraction which allows us to delete our own copy and improves parameter parsing over what we are currently doing. The latter automatically gives us support for objects with type parameters injecting into composable functions. Our tests that run Anvil are also using Anvil's helper for the set up now, I think the issue before was in incompatibility with the kotlin-compile-testing version wer were using.

Closes #256

Comment on lines -52 to +57
val compilation = KotlinCompilation().apply {
configure()
val compilation = AnvilCompilation().apply {
configureAnvil()
kotlinCompilation.configure()
useIR(true)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a helper from Anvil which was previously not working for us. It has its own configureAnvil method so that we don't need our own below anymore

Comment on lines -579 to +597
public val testClass2: TestClass2
public val test: TestClass2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changed because we are now using the parameter name here instead of a name derived from the class.

Copy link
Contributor

@snappdevelopment snappdevelopment left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement 👍
I left one optional comment below

Comment on lines 517 to +523
name = "testClass",
className = ClassName("com.test", "TestClass"),
typeName = ClassName("com.test", "TestClass"),
),
ComposableParameter(
name = "test",
className = ClassName("com.test.other", "TestClass2"),
)
typeName = ClassName("com.test.other", "TestClass2"),
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could remove one of the two. I used two to make sure it is possible to inject multiple parameter, but since we are testing Set and Map as well, this is already covered

@gabrielittner gabrielittner merged commit a1b30b7 into main Jan 27, 2023
@gabrielittner gabrielittner deleted the anvil-2.4.4 branch January 27, 2023 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Support generics for objects injected into composables
2 participants