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

chore(KProperty1.lens): Perform check for data class only once. #3315

Merged
merged 2 commits into from
Dec 19, 2023

Conversation

kyay10
Copy link
Collaborator

@kyay10 kyay10 commented Dec 8, 2023

This PR does the setup work for finding the copy method of the data class and finding the relevant parameter only once, hence failing earlier if used not on a data class

This idea is based on a video by @dmcg.

Copy link
Member

@serras serras left a comment

Choose a reason for hiding this comment

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

Looks good to me. Using a closure to keep the copy is quite clever!

}

@Suppress("UNCHECKED_CAST")
private val <S> KProperty1<S, *>.kClass: KClass<S & Any>
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand 100% why the result here is KClass<S & Any>, instead of merely KClass<*>.

@serras serras merged commit 4f98da7 into arrow-kt:main Dec 19, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants