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

AllowExtraSuspension parameter deprecated, SUSPENDED prefix removed from the output #339

Conversation

avpotapov00
Copy link
Collaborator

Closes #319

2. SUSPENDED prefix removed from the output
@avpotapov00 avpotapov00 requested a review from ndkoval July 9, 2024 01:57
@avpotapov00 avpotapov00 self-assigned this Jul 9, 2024
@avpotapov00 avpotapov00 requested a review from ndkoval July 15, 2024 15:41
src/jvm/main/org/jetbrains/kotlinx/lincheck/Result.kt Outdated Show resolved Hide resolved
src/jvm/main/org/jetbrains/kotlinx/lincheck/Result.kt Outdated Show resolved Hide resolved
src/jvm/main/org/jetbrains/kotlinx/lincheck/Result.kt Outdated Show resolved Hide resolved
src/jvm/main/org/jetbrains/kotlinx/lincheck/Result.kt Outdated Show resolved Hide resolved
}

private fun kotlin.Result<Any?>.toLinCheckResult(wasSuspended: Boolean) =
if (isSuccess) {
when (val value = getOrNull()) {
is Unit -> if (wasSuspended) SuspendedVoidResult else VoidResult
// Throwable was returned as a successful result
is Throwable -> ValueResult(value::class.java, wasSuspended)
else -> ValueResult(value, wasSuspended)
is Throwable -> ValueResult(value::class.java)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't it be ExceptionResult?

Copy link
Collaborator Author

@avpotapov00 avpotapov00 Jul 15, 2024

Choose a reason for hiding this comment

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

No, this is a case when Throwable was returned as a successful result, see comment above

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why should you extract a class in one case and a value in another? ExceptionResult should be a successful one as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose the current code is (and was) buggy here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, I agree, let's treat this case as a regular one, creating ValueResult(value) here.

@avpotapov00 avpotapov00 requested a review from ndkoval July 16, 2024 10:30
src/jvm/main/org/jetbrains/kotlinx/lincheck/Result.kt Outdated Show resolved Hide resolved
}

private fun kotlin.Result<Any?>.toLinCheckResult(wasSuspended: Boolean) =
if (isSuccess) {
when (val value = getOrNull()) {
is Unit -> if (wasSuspended) SuspendedVoidResult else VoidResult
// Throwable was returned as a successful result
is Throwable -> ValueResult(value::class.java, wasSuspended)
else -> ValueResult(value, wasSuspended)
is Throwable -> ValueResult(value::class.java)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose the current code is (and was) buggy here.

@avpotapov00 avpotapov00 requested a review from ndkoval July 17, 2024 10:02
@ndkoval ndkoval merged commit 1a6f1c1 into develop Jul 17, 2024
15 checks passed
@ndkoval ndkoval deleted the 319-always-allow-extra-suspensions-and-do-not-show-suspended-in-the-result-when-an-operation-completes branch July 17, 2024 11:41
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