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

handleErrorWith missing the inline modifier #3547

Closed
PavlosTze opened this issue Dec 9, 2024 · 1 comment
Closed

handleErrorWith missing the inline modifier #3547

PavlosTze opened this issue Dec 9, 2024 · 1 comment

Comments

@PavlosTze
Copy link
Contributor

After upgrading to 2.0.0 I get failed builds with the following reason:

Suspension functions can only be called within coroutine body.

One reproducible case for example throwing this error is:

    suspend fun suspendFunction(): Either<Unit, Unit> {
        val result = Either.Left(Unit)
        return result.handleErrorWith {
            delay(500L)
            Either.Right(Unit)
        }
    }

Notice that we are already in a suspend function so I would expect not to have an issue there calling any other suspend fun.

Currently handleErrorWith has the following signature:
public fun <A, B, C> Either<A, B>.handleErrorWith(f: (A) -> Either<C, B>)
Transforming it to the below by adding the inline modifier as the other functions in Either solves the issue.
public inline fun <A, B, C> Either<A, B>.handleErrorWith(f: (A) -> Either<C, B>)

@serras
Copy link
Member

serras commented Dec 17, 2024

Fixed by #3550

@serras serras closed this as completed Dec 17, 2024
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

2 participants