Skip to content

Conversation

burnoo
Copy link
Contributor

@burnoo burnoo commented Feb 23, 2025

Last version that worked for me with returned Result classes was 1.13.9. I've checked all the commits that were added between 1.13.1 and 1.13.10 and realized that this change was responsible for this behavior.

I've reverted changes, at it looks like all tests are passing (even those added in the below PR that was causing issues). I think the change is not needed anymore and can be simply reverted

However I tested it mostly with Result class, so alternatively I can change this PR to only include workaround for Result:

actual val <T : Any> T.boxedValue: Any?
    @Suppress("UNCHECKED_CAST")
    get() = if (!this::class.isValue_safe) {
        this
    } else {
        val klass = (this::class as KClass<T>)
        val boxedProperty = klass.boxedProperty.get(this)
        if (klass == Result::class) {
            boxedProperty
        } else {
            boxedProperty?.boxedValue
        }
    }

This PR fixes: #1351, #1338

@burnoo burnoo changed the title Fix result value classes Fix returning result values Feb 23, 2025
@burnoo burnoo force-pushed the fix-result-value-classes branch from 6193986 to f990aeb Compare February 23, 2025 18:27
@Raibaz Raibaz merged commit fa404b5 into mockk:master Mar 24, 2025
22 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.

Using coEvery on functions that return kotlin.Result fail with "class kotlin.Result cannot be cast" in 1.13.16
3 participants