You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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
The text was updated successfully, but these errors were encountered: