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

Switch back to kotlin-result 1.x #4

Closed
herrbert74 opened this issue Sep 7, 2024 · 0 comments
Closed

Switch back to kotlin-result 1.x #4

herrbert74 opened this issue Sep 7, 2024 · 0 comments

Comments

@herrbert74
Copy link
Owner

herrbert74 commented Sep 7, 2024

Kotlin (inline) value classes are stable since 1.5.0, but are plagued by issues. There are nearly 400 issues under inline classes:
https://youtrack.jetbrains.com/issue/KT-23338/Inline-classes

So far I ran into issues only with UI tests, and the problem seems to be caused by the mockk mocks of functions that return an inlined version of kotlin-result Result. There is just no way to know for the compiler if the result is wrapped or not, and in my cases it is wrapped again in the test, returning Ok(Ok(x)). Given that the app is relatively small and tested very sparingly, this problem will just grow in the future.

There is a very nice explanation in this ticket, and the author concluded that there is no workaround for these issues, apart from maybe compiler plugins, which is not possible in a lot of cases:
michaelbull/kotlin-result#100

The above author uses v1 in his main project, which is a nice Mastodon client:
https://github.com/pachli/pachli-android

This is a ticket for Retrofit and the platform Result class, seems to be the same problem, probably worth tracking:
https://youtrack.jetbrains.com/issue/KT-53559/JVM-ClassCastException-class-kotlin.Result-cannot-be-cast-to-class-java.lang.String-with-Retrofit

There is not much action on the inline classes, some of the tickets are sitting there for years.

That's blocking KMP as well, it seems, which is not in my focus for now, but good to know for the future:
michaelbull/kotlin-result#110

Given all this I decided to revert back to kotlin-result 1.1.21, which is the final version before 2.0.0.

For reference:
https://kotlinlang.org/docs/inline-classes.html

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

No branches or pull requests

1 participant